docker
-
一:安装docker 1.进入官方文档:https://docs.docker.com/install/linux/docker-ce/centos/ 2.删除原来的docker残留 [root@localhost /]# yum remove docker \ > docker-client \ > docker-client-latest \ > docker-common \ > docker-latest \ > docker-latest-logrotate \ > docker-logrotate \ > docker-engine 3.安装所需的软件包: [root@localhost /]# yum install -y yum-utils \ > device-mapper-persistent-data \ > lvm2 4.设置仓库源: [root@localhost /]# yum-config-manager \ > --add-repo \ > https://download.docker.com/linux/centos/docker-ce.repo 5.安装docker: [root@localhost /]# yum install docker-ce docker-ce-cli containerd.io -y 6.启动docker服务: [root@localhost /]# systemctl enable docker [root@localhost /]# systemctl start docker [root@localhost /]# systemctl status docker 7.通过运行hello-world 映像来验证是否正确安装了Docker Engine-Community [root@localhost /]# docker run hello-world To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/ #这是运行命令之后的回显,可见,docker已经就绪。
-
二:安装加速器 1.注册阿里云账号并进去镜像容器的网页,找到镜像加速器,复制URL: https://vohzpl6l.mirror.aliyuncs.com 2.编辑 /etc/docker/daemon.json 粘贴过去: { "registry-mirrors": ["https://vohzpl6l.mirror.aliyuncs.com"] } 3.重新启动服务ok: systemctl daemon-reload ##这个命令的意思是,后台程序重新加载。 systemctl restart docker
-
拉取centos镜像: 搞一个国内的安装源。 [root@localhost yum.repos.d]# yum-config-manager --add-repo="https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo" 1.[root@localhost /]# docker run centos
-
创建一个httpd的容器 1. [root@localhost ~]# docker run -it centos:latest /bin/bash [root@59b5f2c3575f /]# yum install epel-release #由于这里没有yum仓库,所以先安装仓库才能安装httpd [root@59b5f2c3575f /]# systemctl enable httpd Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service. [root@59b5f2c3575f /]# systemctl start httpd System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down 2. [root@localhost ~]# docker commit -a "zhaoyulong" 59b5f2c3575f httpd:0.1 ##这个是写的运行中的容器信息 sha256:40a4e12380931f94137aa82d2243323d2849fd4913cde5b898d24c5b42f79c37 [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE httpd 0.1 40a4e1238093 About a minute ago 279MB
-
1.创建自己的账号zhaoyulong,并且将本地镜像名增加账号信息 [root@localhost ~]# docker tag 40a4e1238093 zhaoyulong/httpd:0.1 [root@localhost ~]# docker push zhaoyulong/httpd:0.1 The push refers to repository [docker.io/zhaoyulong/httpd] 077ab982bf08: Pushed 9e607bb861a7: Pushed 0.1: digest: sha256:61bab2ffd7946b725374fc4953d580836244c136f154c48034199e19af502f8a size: 741 上传完成。
-
docker commit参数: -a :提交的镜像作者; -c :使用Dockerfile指令来创建镜像; -m :提交时的说明文字; -p :在commit时,将容器暂停。
-
网页查看并更改仓库说明:
c :使用Dockerfile指令来创建镜像;
-m :提交时的说明文字;
-p :在commit时,将容器暂停。
7. ```
网页查看并更改仓库说明: