如果你对该文章中的内容有疑问/不解,可以点击此处链接提问
要注明问题和此文章链接地址 点击此处跳转
mac上的安装
[https://www.docker.com/]()
直接在官网上下载/安装/运行即可
#### 查看版本号: docker version
正确的启动结果如下 Client: Version: 18.03.1-ce API version: 1.37 Go version: go1.9.5 Git commit: 9ee9f40 Built: Thu Apr 26 07:13:02 2018 OS/Arch: darwin/amd64 Experimental: false Orchestrator: swarm Server: Engine: Version: 18.03.1-ce API version: 1.37 (minimum version 1.12) Go version: go1.9.5 Git commit: 9ee9f40 Built: Thu Apr 26 07:22:38 2018 OS/Arch: linux/amd64 Experimental: true
问题:
Is the docker daemon running?
查看: systemctl status docker
启动: systemctl enable docker;systemctl start docker
#### docker 的命令
docker help
Usage: docker COMMAND
A self-sufficient runtime for containers
Options:
--config string Location of client config files (default
"/Users/eric/.docker")
-D, --debug Enable debug mode
-H, --host list Daemon socket(s) to connect to
-l, --log-level string Set the logging level
("debug"|"info"|"warn"|"error"|"fatal")
(default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default
"/Users/eric/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default
"/Users/eric/.docker/cert.pem")
--tlskey string Path to TLS key file (default
"/Users/eric/.docker/key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit
Management Commands:
checkpoint Manage checkpoints
config Manage Docker configs
container Manage containers
image Manage images
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
secret Manage Docker secrets
service Manage services
swarm Manage Swarm
system Manage Docker
trust Manage trust on Docker images
volume Manage volumes
Commands:
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
deploy Deploy a new stack or update an existing stack
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes
Run 'docker COMMAND --help' for more information on a command.
查看当前的镜像: docker images
REPOSITORY TAG IMAGE ID CREATED SIZE 镜像名 latest(最新) 镜像ID(唯一) 时间 大小
查找网上的镜像: docker search *** 如:docker search centos
yuanfangdeMacBook-Pro:~ eric$ docker search centos NAME DESCRIPTION STARS OFFICIAL AUTOMATED centos The official build of CentOS. 4419 [OK] ansible/centos7-ansible Ansible on Centos7 114 [OK] .......
下载镜像:docker pull (镜像名)
上传镜像:docker push (镜像名)
yuanfangdeMacBook-Pro:~ eric$ docker pull ansible/centos7-ansible Using default tag: latest latest: Pulling from ansible/centos7-ansible 45a2e645736c: Downloading [======> ] 9.12MB/70.39MB 1c3acf573616: Downloading [========> ] 9.616MB/59.73MB edcb61e55ccc: Download complete cbae31bad30a: Download complete aacbdb1e2a62: Download complete fdeea4fb835c: Downloading [========> ] 11.28MB/69.68MB
删除镜像:docker rmi 镜像名或id
移除容器:docker rm 容器名
运行容器:docker run -t -i 容器名 执行的命令
-t 让docker分配一个伪终端并绑定在容器的标准输入上
-i 让容器标准输入保持打开
yuanfangdeMacBook-Pro:~ eric$ docker run -t -i ansible/centos7-ansible /bin/bash [root@74683ea5de3b ansible]# ll total 364 -rw-r--r-- 1 root root 137502 Dec 19 2016 CHANGELOG.md -rw-r--r-- 1 root root 10378 Dec 19 2016 CODING_GUIDELINES.md -rw-r--r-- 1 root root 1280 Dec 19 2016 CONTRIBUTING.md -rw-r--r-- 1 root root 35148 Dec 19 2016 COPYING -rw-r--r-- 1 root root 640 Dec 19 2016 MANIFEST.in -rw-r--r-- 1 root root 5044 Dec 19 2016 MODULE_GUIDELINES.md -rw-r--r-- 1 root root 10433 Dec 19 2016 Makefile -rw-r--r-- 1 root root 3772 Dec 19 2016 README.md -rw-r--r-- 1 root root 3048 Dec 19 2016 RELEASES.txt -rw-r--r-- 1 root root 1885 Dec 19 2016 ROADMAP.rst -rw-r--r-- 1 root root 16 Dec 19 2016 VERSION -rw-r--r-- 1 root root 78657 Dec 19 2016 ansible-core-sitemap.xml drwxr-xr-x 2 root root 4096 Dec 19 2016 bin drwxr-xr-x 4 root root 4096 Dec 19 2016 contrib drwxr-xr-x 3 root root 4096 Dec 19 2016 docs drwxr-xr-x 2 root root 4096 Dec 19 2016 docs-api drwxr-xr-x 8 root root 4096 Dec 19 2016 docsite drwxr-xr-x 4 root root 4096 Dec 19 2016 examples drwxr-xr-x 4 root root 4096 Dec 19 2016 hacking drwxr-xr-x 3 root root 4096 Dec 19 2016 lib drwxr-xr-x 9 root root 4096 Dec 19 2016 packaging -rw-r--r-- 1 root root 2077 Dec 19 2016 setup.py -rw-r--r-- 1 root root 1957 Dec 19 2016 shippable.yml drwxr-xr-x 9 root root 4096 Dec 19 2016 test drwxr-xr-x 2 root root 4096 Dec 19 2016 ticket_stubs -rw-r--r-- 1 root root 1193 Dec 19 2016 tox.ini
退出容器: exit
查看运行的容器: docker ps
王明昌博客
