The objective of this tutorial is to install Docker engine and share some useful command line to interact with it.

What’s Docker?

All you need to know about Docker is here

Installation

All is here

Install Portainer.io

Manage docker with GUI

docker run -d -p 9000:9000 --name portainer -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer

See more about portainer.io

Install Docker Compose

Compose is a tool for defining and running multi-container Docker applications… See more here

curl -L "https://github.com/docker/compose/releases/download/1.10.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version

See more here

Useful docker command line

  • Get list of running containers
    sudo docker ps -a 
    
  • kill a container
    sudo docker kill YOUT_CONTAINER_ID
    
  • Remove container
    docker rm CONTAINER_ID
    
  • Get list of images
    sudo docker images
    
  • Remove image
    docker rmi IMAGE_ID
    
  • Interacting with the container
    docker exec -i -t CONTAINER_ID /bin/bash
    
  • Restart docker service
sudo systemctl restart docker
  • Avoid using sudo
groupadd docker
usermod -aG docker YOUR_USER
  • Bind your docker repository in external file system
sudo service docker stop
mv /var/lib/docker /docker
sudo ln -s /docker /var/lib/docker
sudo service docker start
  • Set DOCKER_OPTS
sudo vim /etc/default/docker >> DOCKER_OPTS="-g $(readlink -f /var/lib/docker)"

Install on Raspberry

curl -sSL https://get.docker.com | sh

See more here

systemctl stop docker

mv /var/lib/docker /home/jluccisano/docker

ln -s /home/jluccisano/docker /var/lib/docker

systemctl start docker