Docker
Install Docker
For Ubuntu14.04
sudo apt-get install docker.io
Ubuntu 16.04 預設就會裝了
Start Docker
Run docker daemon
service docker start
不想每次都要加sudo,可以照下面步驟設定
sudo usermod -aG docker {USER}
newgrp docker
service docker restart
希望開機預設喚起docker daemon
將"service docker start"加入到/etc/rc.local
常用指令
docker images //list all images
docker inspect <container id> //lookup container infomation
docker ps //list running container
docker ps -a //list all container
docker rm <container id> //remove container
docker rmi <image id> //remove image
docker start/stop <container id> //start/stop a container
docker run --rm <image name or image id> //run image as container and auto remove conatiner when exit container
docker run -idt <image name or image id> //create and run image as container in background
docker exec -it <container id> /bin/bash //attach into container
- 如果不是以daemon方式跑起container,那在執行完CMD後就會自動結束