A while ago I wandered into docker. These are the notes I use to manage the containers and other stuff I find usable.




A great guide for installing and using Docker


Other Docker guides



Portainer is very usable docker manager.

Find the install docs, requirements etc at


Short Portainer install guide

Become root or run all commands with sudo.

# apt

# apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common

# curl
-fsSL | sudo apt-key add -
# curl -fsSL | sudo apt-key add -

# echo "deb [arch=amd64] buster stable" > /etc/apt/sources.list.d/docker-ce.list
# echo "deb [arch=amd64] focal stable" > /etc/apt/sources.list.d/docker-ce.list

# apt

# apt
install docker-ce

# systemctl status docker

# usermod
-aG docker sorin

# docker volume create portainer_data

# docker volume ls

# docker run -d --name=Portainer --hostname=Portainer --network=host --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data -e TZ='Europe/Stockholm' portainer/portainer-ce

Upgrading to new versions # docker pull portainer/portainer-ce:latest

Run docker ps to find the old container's id
# docker ps
# docker stop <old portainer id>
# docker rm <old portainer id>

Now start the upgraded version instead # docker run -d --name=Portainer --hostname=Portainer --network=host --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data -e TZ='Europe/Stockholm' portainer/portainer-ce

When done, browse to http://serverip:9000 to confirm it works and to create your first user.
Choose Local when the instal wizard asks for the installation type.

Portainer templates repos

Some third party template repos for Portainer as well as the default one.

Copy and paste the repo url to left panel settings menu in the URL field at App Templates header.


Backing up docker containers, volumes etc


Docker Compose

Your goto solution when you start creating stacks instead.



Creating stuff with Docker Compose


Docker commands

Install busybox

# docker pull busybox

Run it

# docker run busybox


List containers

# docker ps -a
CONTAINER ID   IMAGE                                COMMAND        CREATED      STATUS        PORTS                                                               NAMES
a3b2c696a51d   jlesage/nginx-proxy-manager:latest   "/init"        4 days ago   Up 30 hours>4443/tcp,>8080/tcp,>8181/tcp   nginx-proxy-manager
5252b616bacc   portainer/portainer-ce               "/portainer"   5 days ago   Up 30 hours>8000/tcp,>9000/tcp                      portainer


Run a web app

# docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce


List used ports for a particular container

# docker port portainer
8000/tcp ->
9000/tcp ->


Stop the container

# docker stop portainer


Show status inside the container

See the container ID from docker ps -a.

# docker top a3b2c696a51d


Container image managment

List container images
# docker image ls

Remove container images
# docker image rm <image ID>

Remove all container images
# docker image prune -a

Stop all containers
# docker stop $(docker ps -a -q)

Remove all containers
# docker rm $(docker ps -a -q)


Run, pull and remove a container

# docker run hello-world   
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete  
Digest: sha256:95ddb6c31407e84e91a986b004aee40975cb0bda14b5949f6faac5d2deadb4b9
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
   executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
   to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:

For more examples and ideas, visit:

# docker ps -a
CONTAINER ID   IMAGE                                COMMAND        CREATED              STATUS                          PORTS                                                               NAMES
85f5701571cf   hello-world                          "/hello"       About a minute ago   Exited (0) About a minute ago                                                                       ecstatic_lamarr

# docker rm 85f5701571cf


Ssh to a container

# docker exec -it MYSQL2 /bin/bash



Build a container with docker-compose

Use eg this simple script to install Nginx Proxy Manager:

# cd /home/user/docker
# ll
-rw-r--r--  1 user user  850 Feb 12 14:35 docker-compose.yml
# docker-compose build

Restart the container with changes from above build # docker-compose up -d













Stop Spam Harvesters, Join Project Honey Pot


Get a free SSL certificate!


The leading nonprofit defending digital privacy, free speech, and innovation.


The Linux Foundation provides a neutral, trusted hub for developers and organizations to code, manage, and scale open technology projects and ecosystems.


Kubuntu is an operating system built by a worldwide community of developers, testers, supporters and translators.


 43ef5c89 CanonicalUbuntudarktext