Reference :
https://docs.docker.com/
https://docs.docker.com/engine/userguide/basics/
http://philipzheng.gitbooks.io/docker_practice/content/
http://www.openfoundry.org/tw/tech-column/9319-docker-101
http://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach
1. Installation
1. yum install docker
Note:
FirewallD
CentOS-7 introduced firewalld, which is a wrapper around iptables and can conflict with Docker.
When
firewalld
is started or restarted it will remove the DOCKER
chain from iptables, preventing Docker from working properly.
When using systemd,
firewalld
is started before Docker, but if you start or restart firewalld
after Docker, you will have to restart the Docker daemon.2. service docker start (/bin/systemctl start docker.service)
3. chkconfig docker on (systemctl enable docker.service)
2. Image
1. Search image with CentOSdocker search centos2. Download image
docker pull centos3. List local image
docker images
3.Container
1. List all containerdocker ps -a
2. Start / Stop / Restart a container
docker start|stop|restart container-id3. List all container
docker ps -a4. Init a container ( create and run )
docker run -dit --name myCentOS6 centos:centos65. Start / Stop / Restart a exist container
docker start|stop|restart container-id6. Attach (go back) to a container
docker attach containuer-id7. De-attach (leave) a container
EX :
docker run -dit --name myCentOS6 centos:centos6
docker attach myCentOS6
in the container, ctrl+p then ctrl+q
EX :
docker run -dit --name myCentOS6 centos:centos6
docker attach myCentOS6
ctrl + p , ctrl + q
(if we use exit to leave the bash, the container will stop because we "close" the last container job)
8. Run a new job in a container
docker exec container-id job
EX: docker run myCentOS6
9. show a container info
docker inspect container-id job
EX: docker run myCentOS6
沒有留言:
張貼留言