yum remove docker docker-engine docker.io containerd runc
yum install -y yum-utils device-mapper-persistent-data lvm2 //安装依赖
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sed -i 's+download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo
yum makecache fast
yum install docker-ce
systemctl restart docker //更新服务
docker version
docker info //查看docker配置文件
apt-get remove docker docker-engine docker.io containerd runc
apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
sudo add-apt-repository \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt update //更新仓库
apt-get update
apt-get install docker-ce
docker pull centos
docker run -it docker.io/centos/bin/bash
#创建目录环境
cd /opt/
mkdir dockerfile/{web/{nginx,tomcat,jdk,apache},system/{centos,ubuntu,redhat}}
cd dockerfile/web/nginx
pwd
/opt/dockerfile/web/nginx
#编写DockerFile
vim ./Dockerfile
RUN rpm-ivh http:mirrirs.aliyun.com/epel/epel-release-latest-7.noarch.rpm
RUN yum -y install vim wget tree lrzsz gcc gcc-c++ automake pcre pcre-devel zlib zilb-devel
//自动解压包
openssl openssl-devel iproute net-tools iotop
ADD nginx-1.10.3.tar.gz /usr/local/src/
RUN cd /usr/local/src/nginx-1.10.3 && ./configure -prefix=/usr/local/nginx
--with-http_sub_module && make && make install
RUN cd/usr/local/nginx/
ADD nginx.conf /usr/local/nginx/conf/nginx.conf
RUN useradd nginx-s /sbin/nologin
RUN in -sv /usr/local/nginx/sbin/nginx /usr/sbin/nginx
RUN echo "test nginx page"> /usr/local/nginx/html/nginx.html
EXPOSE 80 443
CMD["nginx"]
准备配置文件
cp /usr/local/nginx/conf/nginx.conf
cp /usr/local/src/nginx-1.10.3.tar.gz //nginx源码
执行镜像构建文件
docker build -t jack/nginx-1.10.3:v1
/opt/dockerfile/web/nginx/
docker images //查看是否构建生成本地镜像
docker run -d -p 80:80 --name yum-nginx jack/nginx-1.10.3:v1 /usr/sbin/nginx //镜像中启动容器
docker ps -a //查看
Docker Hub Container Image Library | App Containerization
docker login http://hub.docker.com/
#查看认证信息
cat ./docker/config.json
#上传镜像的tag
docker images //查看镜像ID
docker tag +具体地址
docker login
docker push dockers.io/xxxx
docker login // 上传进度
docker lohin http://hub.docker.com
docker run -it docker.io/xxx
本文来自博客园,作者:林清|Julien,转载请注明原文链接:https://www.cnblogs.com/Julien1021/p/16355898.html