Docker容器指南
作者 |
联络方式 |
lovesea |
Q 群:368973565 微信:nuanshoutx |
Docker安装
原文链接 https://store.docker.com/editions/community/docker-ce-server-centos?tab=description
Docker CE is supported on CentOS 7.3 64-bit.
1. Set up the repository
Set up the Docker CE repository on CentOS:
sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
sudo yum makecache fast
2. Get Docker CE
Install the latest version of Docker CE onCentOS:
sudo yum -y install docker-ce
Start Docker:
sudo systemctl start docker
3. Test your Docker CE installation
Test your installation:
sudo docker run hello-world
Docker加速器
去官网注册账号 https://dashboard.daocloud.io/services
curl-sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -shttp://629db2db.m.daocloud.io
该脚本可以将 --registry-mirror加入到你的 Docker配置文件 /etc/default/docker中。适用于 Ubuntu14.04、Debian、CentOS6、CentOS7、Fedora、Arch Linux、openSUSE Leap 42.1,其他版本可能有细微不同
Docker常用命令
1. 列出镜像docker images
2. 退出容器exit
3. 查询docker中运行的容器 docker ps
4. 显示所有容器: docker ps–a
5. 如何进入容器 docker exec -it xiaohaibing/javaweb:0.1/bin/bash
6. 删除容器 docker rm /javaweb
7. 登录现有运行容器 docker attachb3a1c9490901 容器ID
8. 创建镜像
docker commit 57c312bbaad1huangyong/javaweb:0.1
该容器的 ID 是“57c312bbaad1”,所创建的镜像名是“huangyong/javaweb:0.1”,随后可使用镜像来启动 Java Web 容器。
9. 查看容器详情
docker inspect -f {{.Config.Volumes}} dev_tomcat2容器id
Docker坑
1. ls: cannot open directory .:Permission denied
宿主机上执行以下命令
$ setenforce 0
参考文章
1. http://www.codeceo.com/article/docker-java-web-runtime.html