2015年11月27日 星期五

Docker @ CentOS 7.0


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 CentOS
docker search centos
2. Download image
docker pull centos
3. List local image
docker images

3.Container

1. List all container
docker ps -a


2. Start / Stop / Restart a container
docker start|stop|restart container-id
3. List all container
docker ps -a
4. Init a container ( create and run )
docker run -dit --name myCentOS6 centos:centos6
5. Start / Stop / Restart a exist container
docker start|stop|restart container-id
6. Attach (go back) to a container
docker attach containuer-id
EX :
docker run -dit --name myCentOS6 centos:centos6
docker attach myCentOS6
 7. De-attach (leave) a container
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






沒有留言:

張貼留言