JustToThePoint English Website Version
JustToThePoint en español
JustToThePoint in Thai

Docker: A Step by Step Guide. Docker compose and Portainer.

Introduction

Docker is a software platform designed to make it easier to create, deploy, and run applications by using containers. It offers OS-level virtualization to deliver software in packages called containers.

  1. First, we will update and upgrade the system: sudo apt-get update && sudo apt-get upgrade
  2. Let’s install Docker using the following command: sudo apt install docker.io. Let’s know the Docker version information: docker ‐‐version. Check whether Docker is running: sudo systemctl status docker
  3. We should start Docker and make it enable automatically on system boot: sudo systemctl enable ‐‐now docker.
  4. Add your user to the docker group: sudo usermod -aG docker ${USER}.
  5. It’s time to test it: docker run hello-world.
  6. List all Docker containers: docker container ls -a. Stop a specific container: docker container stop [container_id] or all containers: docker container stop $(docker container ls –aq). Remove a stopped container: docker container rm [container_id] or all containers: docker container rm $(docker container ls –aq).
  1. First, we will update and upgrade the system: sudo apt-get update && sudo apt-get upgrade
  2. Download (curl) and execute the installation script: curl -sSL https://get.docker.com​ | sh
  3. Add a non-root user (pi) to the docker group: sudo usermod -aG docker pi
  4. Check Docker version (docker version) and test it by running the Hello World container: docker run hello-world
  1. Install the necessary packages: sudo pacman -Syy docker docker-compose
  2. Start the docker service on startup: sudo systemctl start docker.service, sudo systemctl enable docker.service
  3. Add our user to the Docker group: sudo usermod -aG docker $USER
  4. Test it: docker run hello-world

Docker compose

Docker compose is a tool for running multi-container applications on Docker.

  1. Let’s install it. First, we need to install some dependencies: sudo apt-get install -y libffi-dev libssl-dev. sudo apt-get install -y python3 python3-pip. sudo apt-get remove python-configparser. Next, we install docker compose: sudo pip3 -v install docker-compose.
  2. List all running Docker containers: sudo docker ps. List all containers, both running and stopped: sudo docker ps –a.
  3. Delete containers: docker rm IdContainer. Delete all “exited” containers: docker container prune.
  4. Start a stopped docker container: docker start IdContainer. Start a container in interactive mode: docker run -it ubuntu.

Portainer

  1. Installation:

        # 1. Pull the latest version:
        sudo docker pull portainer/portainer-ce:latest
        # 2. Run this container.
        sudo 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:latest
    

    We define the ports we want Portainer to have access to, a name (“portainer”), and we also tell the Docker manager that we want to restart this Docker if it is ever unintentionally offline.

  2. Use: Firstly, open your favorite browser and type the following:

        http://[PI_ADDRESS]:9000 # If you don't remember your PI's IP address, type: hostname -I
    

    Secondly, upon launching Portainer’s web interface, you will need to create an admin account.

    What sort of container environment we want Portainer to manage? Select Docker. Click on Containers and you will be presented with a list of containers currently set up on your device. If you want to add a new one, click the Add container button.

Bitcoin donation

JustToThePoint Copyright © 2011 - 2023 Anawim. ALL RIGHTS RESERVED. Bilingual e-books, articles, and videos to help your child and your entire family succeed, develop a healthy lifestyle, and have a lot of fun.

This website uses cookies to improve your navigation experience.
By continuing, you are consenting to our use of cookies, in accordance with our Cookies Policy and Website Terms and Conditions of use.