Docker and Portainer

Posted under » Ubuntu » Linux on 27 Apr 2024

Right now I don't have time to explain why we should be using docker but it is hard to ignore it. Install according to your specs. Maybe next time I explain in detail.

$ apt install apt-transport-https ca-certificates curl software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu jammy stable"
$ apt-cache policy docker-ce
$ apt install docker-ce
$ systemctl status docker
$ docker info

Docker containers are built from Docker images. By default, Docker pulls these images from Docker Hub. Let's test if we can pull an image.

$ docker run hello-world

To look at your local images

$ docker images

To see running dockers

$ docker ps
$ docker ps -a

To start a stopped container, use docker start, followed by the container ID. To stop a running container, use docker stop, followed by the container ID or namei. Once you’ve decided you no longer need a container anymore, remove it with the docker rm.

$ docker start 1c08a7a0d0e4
$ docker stop ubuntu
$ docker rm ubuntu

Maybe this is all too hard to remember so I recommend that you docker this app called Portainer

Portainer needs persisting data (for storing user password for example). Let's create a docker volume to store this data.

$ docker volume create portainer_data
$ docker volume inspect portainer_data 

Now run it on port 9000

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

Here is the detail of each option:

The first time Portainer starts, it asks you to set a password. The password must be at least 12 characters. Once the password is entered, you are in business.

web security linux ubuntu python django git Raspberry apache mysql php drupal cake javascript css AWS data