docker学习笔记1
- 作者: 五速梦信息网
- 时间: 2026年04月04日 13:44
技术资料
docker中文官网:http://www.docker.org.cn/
中文入门课程:http://www.docker.org.cn/book/docker.html
docker学习笔记:http://www.open-open.com/lib/view/open1423703640748.html
深入浅出docker:http://www.infoq.com/cn/articles/docker-core-technology-preview
在centos7中,docker的默认配置在/usr/lib/systemd/system/docker.service,可以做一些配置:
- –insecure-registry 127.0.0.1:5000 Docker 1.3版本后,与registry交互默认使用https,配置后表示跟该仓库交互形式为http
使用
search
docker search –help Usage: docker search [OPTIONS] TERM Search the Docker Hub for images –automated=false Only show automated builds
–help=false Print usage
–no-trunc=false Don‘t truncate output
-s, –stars=0 Only displays with at least x stars
如果要搜索非docker hub上的镜像,可以增加仓库地址
pull
docker pull –help
Usage: docker pull [OPTIONS] NAME[:TAG|@DIGEST] Pull an image or a repository from the registry -a, –all-tags=false Download all tagged images in the repository
–help=false Print usage
在下载的时候,可以使用TAG,默认下载的是latest,默认是从docker hub上下载,如果要从docker hub的个人仓库中下载,需要加上个人账号前缀
docker pull sailor/mycentos
从docker hub的sailor用户仓库上下载mycentos镜像
也可以显示指定不从docker hub上下载,比如
docker pull dl.dockerpool.com:5000/centos
表示从dl.dockerpool.com:5000上下载centos镜像
run
docker run –help Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG…] Run a command in a new container -a, –attach=[] Attach to STDIN, STDOUT or STDERR
–add-host=[] Add a custom host-to-IP mapping (host:ip)
–blkio-weight=0 Block IO (relative weight), between 10 and 1000
-c, –cpu-shares=0 CPU shares (relative weight)
–cpuset-cpus= CPUs in which to allow execution (0-3, 0,1)
–cpuset-mems= MEMs in which to allow execution (0-3, 0,1)
-d, –detach=false Run container in background and print container ID
…
…
docker run参数很多,包括指定容器运行资源(CPU/MEM等),以及一些其它参数,常用:
docker run -t -i centos /bin/bash
-t表示启动一个tty(控制台), -i表示开启stdin输出,/bin/bash表示在镜像中执行/bin/bash命令
commit
当对镜像做了修改后,想重新提交的时候,需要用到commit命令
docker commit –help Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]] Create a new image from a container’s changes -a, –author= Author (e.g., “John Hannibal Smith <hannibal@a-team.com>”)
-c, –change=[] Apply Dockerfile instruction to the created image
–help=false Print usage
-m, –message= Commit message
-p, –pause=true Pause container during commit
push
- 在docker hub中注册一个账户,比如注册账户为sailor
- 在本机进行docker login,需要填写参数:username password email等
- 将原来的镜像打标签成 {username}/xxx,比如讲centos镜像通过打标签成 sailor/mycentos
- 使用docker push将其发布到docker hub的sailor账户的仓库中
相关文章
-
Docker学习笔记之一,搭建一个JAVA Tomcat运行环境
Docker学习笔记之一,搭建一个JAVA Tomcat运行环境
- 互联网
- 2026年04月04日
-
Docker学习记录
Docker学习记录
- 互联网
- 2026年04月04日
-
docker学习书籍
docker学习书籍
- 互联网
- 2026年04月04日
-
docker学习笔记(一)—— ubuntu16.04下安装docker
docker学习笔记(一)—— ubuntu16.04下安装docker
- 互联网
- 2026年04月04日
-
Docker学习笔记
Docker学习笔记
- 互联网
- 2026年04月04日
-
dockerѧϰ(1)
dockerѧϰ(1)
- 互联网
- 2026年04月04日






