Skip to content

Portainer container setup

Introduction

Portainer CE empowers you to efficiently manage all your orchestrator resources, including containers, images, volumes, and networks. Effortlessly deploy and efficiently manage containers with the toolkit and graphical user interface.

Setup

  1. Create the folders needed by the container

    Run the following commands inside your home folder:

    # Open your terminal application
    cd ~
    mkdir -p portainer/data
    cd portainer
  2. Generate an encrypted password (needed once)

    Apache2-utils is required, make sure this package is installed and then run the following command:

    # Open your terminal application
    htpasswd -nb -B admin <password> | cut -d ":" -f 2
    # IMPORTANT: Please read the instructions below
    Instructions:
    • Required Replace <password> with your password

    Save the result of the htpasswd command.

  3. Create the script needed to run the container

    Save the following script as portainer_run.sh:

    portainer_run.sh
    # To create this script use your text editor application, for example Nano
    docker run -d \
    --init \
    --hostname=portainer \
    --name=portainer \
    -p 9443:9443 \
    -p 8000:8000 \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v $PWD/data:/data \
    -e TZ="Europe/Amsterdam" \
    --restart=unless-stopped \
    --cap-add=NET_ADMIN \
    portainer/portainer-ce \
    --no-analytics \
    --admin-password=’<password> \
    # IMPORTANT: Please read the instructions below
    Instructions:
    • Optional Replace docker with podman if needed
    • Required Replace port number 8000 or 9443 (on the left side of :) with a port number that is available if needed.
    • Optional Replace $PWD/data with the location of your data if needed. This can be a fileserver mount
    • Required Replace Europe/Amsterdam with your own timezone
    • Optional Remove --no-analytics if you want to enable analytics
    • Required Replace <password> with the enrypted password you generated with htpasswd
  4. Run the script to create the container

    Run the following command:

    # Open your terminal application
    sudo sh portainer_run.sh

    The image portainer/portainer-ce is automatically pulled and the container is created. By default, Portainer generates and uses a self-signed SSL certificate to secure port 9443.

  5. Check the results

    If needed you can check if the container is running properly.

    Now you can log into Portainer with admin and the password used before by opening a web browser and going to: https://localhost:9443. Replace localhost with the relevant IP address or FQDN if needed, and adjust the port if you changed it earlier.

    The Environment Wizard will automatically launch and will help get you started with Portainer.

Favorites

Comments

    No comments found for this note.

    Join the discussion for this note on Github. Comments appear on this page instantly.

    Copyright 2021- Fiction Becomes Fact