JustToThePoint English Website Version
JustToThePoint en español

Maximize your online presence with our exclusive offer: Get a stunning hero banner, the hero you need and deserve, at an unbeatable price! Bew, 689282782, bupparchard@gmail.com

Docker, docker compose, Portainer. Distrobox.

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. Image

  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

Portainer is a lightweight management UI witch allows you to easily create, manage, and delete your Docker containers

  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.

Distrobox

If you’ve used Arch Linux, you’re probably familiar with how easy it is to alter or even break your system inadvertently. However, containerized environments provide a reliable solution: you can set up containers for specific tasks, isolating applications and configurations to keep your system intact.

Distrobox

    sudo pacman -S distrobox podman # Distrobox allows you to create and manage containers on your favorite Linux distribution using either Docker or Podman.

Using Distrobox as a native user space environment is an excellent way to keep your system clean and stable, particularly if you’re not yet ready to switch to an immutable Linux desktop. Remember, with mutable systems, any changes or configuration drifts are permanent!

Setting up a Distrobox Environment

Create, enter, and manage containers effortlessly with Distrobox commands:

distrobox create -i archlinux # Create a Container from an image (in this case, Arch Linux)
distrobox enter archlinux # Access a Distrobox Container or use: distrobox-enter --name container-name

Once inside the container, you can install and update applications without affecting the host system. Here are a few commands to get you started:

sudo pacman -S vlc flameshot neofetch # Install apps within the container
sudo pacman -Syu gimp  # Update applications in the container
sudo pacman -S libcanberra-pulse # A library for PulseAudio sound server support

If you prefer, you can run commands directly in the Distrobox container without accessing the shell each time: distrobox enter nameContainer ‐‐ distrobox-export ‐‐app nameApp, e.g., distrobox enter archlinux ‐‐ distrobox-export ‐‐app gimp

Make sure you’re running this command from your host system, not from inside the container

Managing Containers

Distrobox also provides commands for managing your containers effectively:

distrobox stop archlinux  # Stop a container.
distrobox create --name arch2 --clone archlinux  # Clone an existing container.
distrobox rm arch2 # Remove a container.
distrobox list  # List all containers.
distrobox-upgrade --all # Upgrade all containers' packages.

This last command, distrobox-upgrade ‐‐all, will enter each container, use its package manager, and perform an upgrade for each one.

Common Issue: “Cannot Open Display” Error

A frequent error when running GUI applications in a container is “Cannot open display”, which suggests that the GUI application cannot access the X server display. This issue generally arises due to problems with X11 forwarding or lack of permissions to access the X server.

To resolve this issue, ensure that your user is permitted to connect to the X server:

    sudo pacman -S xorg-xhost # Install xorg-xhost.
    vim .zshrc: # Open the .zshrc file in Vim
    xhost +si:localuser:$USER

Open your .zshrc file to include the command xhost +si:localuser:$USER.

Bitcoin donation

JustToThePoint Copyright © 2011 - 2024 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. Social Issues, Join us.

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.