Tuesday, May 23, 2017

Docker Docker Docker

Some useful docker commands:

Install docker
sudo apt-get install docker.io
Remove all docker images
docker rmi $(docker images -a -q)
Remove all exited containers and dangling images
docker rm $(docker ps -a -f status=exited -q)
docker rmi -f $(docker images -f "dangling=true" -q)
Stop all running containers
docker stop $(docker ps -a -q)
Connect to a running container
docker exec -it ContaineridOrName bash
Run a docker container and interact with the container
docker run -it --rm busybox
Normally a regular user can not run docker because of the permissions, the following command assume that a use group named "docker" has been created during the docker install, then you can the following command to add the current logged in user to the docker group, then refresh the group, the current user will be able to manipulate docker as the root user:
sudo gpasswd -a $USER docker
newgrp docker 
sudo chmod 666 /var/run/docker.sock 


No comments:

Post a Comment