Docker on Linux

Once docker is started, enable it to start automatically

sudo systemctl enable docker

If you are behind a proxy, you need to set the proxy server

sudo mkdir -p /etc/systemd/system/docker.service.d
sudo vi /etc/systemd/system/docker.service.d/http-proxy.conf

Put the following in this file

[Service]
Environment="HTTP_PROXY=http://192.168.1.1:3128"

Now restart to take effect

sudo systemctl daemon-reload
sudo systemctl restart docker
systemctl show --property=Environment docker

The last command should show the proxy server. Now test that docker is working

docker run hello-world

For a non-root user to run docker, you must add them to docker group

sudo usermod -aG docker USERNAME

See installed docker images

docker images

Delete an image

docker rmi <IMAGE ID>

To see all containers

docker ps -a

To remove a container

docker rm <CONTAINER ID>

Stop and remove all docker containers

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)