其他分享
首页 > 其他分享> > Docker镜像

Docker镜像

作者:互联网

四、Docker镜像(image)

# docker info |grep "Storage Driver"
Storage Driver: overlay2
Sponsor Registry
Mirror Registry
Vendor Registry
Private Registry
Image Repositories  镜像仓库
Automated Build  自动构建
Webhooks  可以将GitHub中的dockerfile自动构建为镜像
Organizations  组织
GitHub and Bitbucket integration
  build       Build an image from a Dockerfile
  history     Show the history of an image
  import      Import the contents from a tarball to create a filesystem image
  inspect     Display detailed information on one or more images
  load        Load an image from a tar archive or STDIN
  ls          List images
  prune       Remove unused images
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rm          Remove one or more images
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  1. 手工组织文件系统,打包成docker image
  2. 基于容器制作,在运行的容器上commit将可写层制作成image
  3. 基于Dockerfile手动build或者自动构建,Dockerfile基于Base image制作
# docker pull centos:centos7.5.1804
# docker run --name centos -it centos:centos7.5.1804
[root@xxxxxxxxxxx /]# yum install vim wget lftp bash-completion net-tools bind-utils telnet screen tree psmisc bc httpd -y
# docker commit -p centos
# docker image ls
<none>                   <none>              484173886091        22 seconds ago      362MB
# docker tag 484173886091 dongfeimg/mycentos:v0.1
# docker image ls
dongfeimg/mycentos       v0.1                484173886091        5 minutes ago       362MB
# docker run --name mycentos -it dongfeimg/mycentos:v0.1
[root@3c21ac1d0496 /]# mkdir -p /data/html/
[root@3c21ac1d0496 /]# vim /var/www/html/index.html
<h1>Welcome Dongfei website.</h1>
# docker commit -a "Dongfei" -c 'CMD ["/usr/bin/systemctl","start","httpd"]' -p mycentos dongfeimg/mycentos:v0.2
# docker run --name mycentos2 --privileged=true -d dongfeimg/mycentos:v0.2 /usr/sbin/init
[root@docker ~]# docker exec -it 7cec67f74460 bash
[root@7cec67f74460 /]# systemctl start httpd
# docker inspect 7cec67f74460 |grep IPAddress
"IPAddress": "172.17.0.4",
# curl 172.17.0.4
<h1>Welcome Dongfei website.</h1>
# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: dongfeimg
Password: ******
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
# docker push dongfeimg/mycentos:v0.1
# docker push dongfeimg/mycentos:v0.2
# docker save -o myimages.gz centos:centos7.5.1804 dongfeimg/mycentos:v0.1
# docker load -i myimages.gz
# docker save $(docker images | grep -v REPOSITORY | awk 'BEGIN{OFS=":";ORS=" "}{print $1,$2}') -o images_name.gz

标签:dongfeimg,image,mycentos,images,镜像,Docker,docker
来源: https://www.cnblogs.com/L-dongf/p/11028723.html