您的位置:首页 > 运维架构 > Docker

Docker

2016-05-23 18:08 537 查看
Install:

安装完成后需要sudo usermod -aG docker [user]后重新登录,以非root用户使用docker。

docker run command时,报docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?检查docker是否已启动,ps -aux | grep docker,若已启动依然报此错误,一般是用户导致的,可sudo执行,或添加docker用户。

docker run hello-world

run:创建并运行一个docker container,container是极简的linux操作系统

hello-world:加载名为hello-world的image进这个container,image是加载进container的程序

Docker Hub:全球共享docker image库。

构建image:

mkdir mydocker && cd mydocker

vim Dockerfile

docker build -t docker-whale . # 读取当前目录下的Dockerfile,构建名为docker-whale的image

docker run docker-whale

docker images

# REPOSITORY TAG IMAGE ID CREATED SIZE

# docker-whale latest bd523f778016 About an hour ago 274.5 MB

# hello-world latest 94df4f0ce8a4 3 weeks ago 967 B

# docker/whalesay latest 6b362a9f73eb 12 months ago 247 MB
docker tag bd523f778016 [account]/docker/whalesay latest # 用image-id和docker-hub-account和image名称标记image

docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

# docker-whale latest bd523f778016 About an hour ago 274.5 MB

# yimzncy/docker-whale latest bd523f778016 About an hour ago 274.5 MB

# hello-world latest 94df4f0ce8a4 3 weeks ago 967 B

# docker/whalesay latest 6b362a9f73eb 12 months ago 247 MB

sudo docker login --username=[account] --email=[account]@gmail.com # 登录docker hub

docker push docker/whalesay # push image

docker rmi -f bd523f778016/docker-whale # 删除image可用id或name

docker run [account]/docker/whalesay # pull && load image

MORE:
https://docs.docker.com/docker-hub/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: