Docker basis
Last updated
Was this helpful?
Last updated
Was this helpful?
对应系统下载.
安装好,在托盘图标可以看到状态,启动成功
查看版本
docker image COMMAND
show containers
docker image ps
基本命令平时就查看,其他build等简单使用
docker container COMMAND
show containers
docker container ls [-a] 显示全部(包含未运行的)
image就是镜像,静态的,通过image可以生成container
docker pull COMMAND
拉取image
docker run COMMAND
docker run --name name -d imagename
通过image创建container并运行 -d,dettach
开放端口
docker run -p outer:inner imagename
outer: 外部端口 inner: 内部端口
比如 8080:80 ,外部宿主计算机端口映射到docker内部80端口
开放多个端口
-p 8080:80 -p 2222:222 -p etc...
删除container
docker rm -f containername
删除image
docker rmi imagename
share file from host
docker run --name name -v /some/folder:/usr/local/nginx/html:ro -p 8080:80 nginx:latest
going inside container
docker exec -it containername bash(/bin/sh)
Dockerfile
docker build
docker push
推送到duckerhub或者其他docker仓库
.dockerignore
Rule
Behavior
# comment
Ignored.
*/temp*
Exclude files and directories whose names start with temp
in any immediate subdirectory of the root. For example, the plain file /somedir/temporary.txt
is excluded, as is the directory /somedir/temp
.
*/*/temp*
Exclude files and directories starting with temp
from any subdirectory that is two levels below the root. For example, /somedir/subdir/temporary.txt
is excluded.
temp?
Exclude files and directories in the root directory whose names are a one-character extension of temp
. For example, /tempa
and /tempb
are excluded.
此文件忽略通过规则定义的文件 然而,往往忽略的,需要在dockerfile
中重新RUN
来在部署时候生成module
等
Alpine
很精简的,体积很小.适合集成docker中
一个使用例子 36.8MB