Press "Enter" to skip to content

Portainer Usage

0

Install Docker and Portainer

By default, Portainer store its data inside the container in the /data folder on Linux (C:\\data on Windows).
You’ll need to persist Portainer data to keep your changes after restart/upgrade of the Portainer container.  Docker Deploy document: https://portainer.readthedocs.io/en/latest/deployment.html . You can use a bind mount on Linux to persist the data on the Docker host folder:
root@Ubuntu18:/# curl -sSL https://get.docker.com/ | sh
root@Ubuntu18:/# docker volume create portainer_data

root@Ubuntu18:/# 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:latest

root@Ubuntu18:/# which docker

root@Ubuntu18:/# find . -type d -name "portainer_data"
./var/lib/docker/volumes/portainer_data

You can try out the public demo instance: http://demo.portainer.io/ (login with the username admin and the password tryportainer).

Update Portainer

1. Update image

root@Ubuntu18:/# docker stop portainer
portainer
root@Ubuntu18:/# docker pull portainer/portianer
Using default tag: latest
Error response from daemon: pull access denied for portainer/portianer, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
root@Ubuntu18:/# docker pull portainer/portainer
Using default tag: latest
latest: Pulling from portainer/portainer
d1e017099d17: Already exists
292b789be2e4: Pull complete
Digest: sha256:63eb47d4b408c3f39e942368bcbf7e157a2b6e5dda94ffd403a14199e1137133
Status: Downloaded newer image for portainer/portainer:latest
docker.io/portainer/portainer:latest
root@Ubuntu18:/# docker start portainer
portainer

some os, you might need to use command “docker pull docker.io/portainer/portainer”

If you could not find image, just use command “docker search portainer”

Or:

 docker service update --image portainer/portainer:latest portainer

2. Delete Container and Re-create Portainer with new image

root@Ubuntu18:/# docker container rm 4cf95554b471
Error response from daemon: You cannot remove a running container 4cf95554b471baa13e15e016a19ceacfdd7d2cb0e5ee5d0d5be837c521168691. Stop the container before attempting removal or force remove
root@Ubuntu18:/# docker stop portainer
portainer
root@Ubuntu18:/# docker container rm 4cf95554b471
4cf95554b471
root@Ubuntu18:/# 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:latest
00754dc1b66c469edd162c4993a0d63fe6ce14f01a928c34bad98f955071f297
root@Ubuntu18:/#

3. Delete old image
Docker image ls
docker image rm <image id>

YouTube Video:

A useful command to get rid of the stopped containers:
docker rm `docker ps -a -q`

Check Container

root@Ubuntu18:/# docker container ls -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
a9ea9891aa03        nginx:latest        "nginx -g 'daemon of…"   4 weeks ago         Up 4 weeks          0.0.0.0:80->80/tcp       nginx1
4cf95554b471        4cda95efb0e4        "/portainer"             4 weeks ago         Up 11 minutes       0.0.0.0:9000->9000/tcp   portainer
root@Ubuntu18:/# docker stats
CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
a9ea9891aa03        nginx1              0.00%               3.172MiB / 982.2MiB   0.32%               64.1MB / 132MB      14.6MB / 0B         3
4cf95554b471        portainer           0.01%               11.3MiB / 982.2MiB    1.15%               4.55MB / 50.2MB     90.7MB / 238MB      10

Log into Container

[root@centos1docker ~]# docker ps
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                    NAMES
26a4cc3a312a        nginx:latest          “nginx -g ‘daemon of…”   24 hours ago        Up 16 minutes       0.0.0.0:80->80/tcp       portainer-nginx1
d5c3f33bd8ee        portainer/portainer   “/portainer”             25 hours ago        Up 25 hours         0.0.0.0:9000->9000/tcp   portainer
[root@centos1docker ~]#

[root@centos1docker ~]# docker exec -it portainer-nginx1 /bin/bash
root@26a4cc3a312a:/#
root@26a4cc3a312a:/# cat /etc/os-release
PRETTY_NAME=”Debian GNU/Linux 10 (buster)”
NAME=”Debian GNU/Linux”
VERSION_ID=”10″
VERSION=”10 (buster)”
VERSION_CODENAME=buster
ID=debian
HOME_URL=”https://www.debian.org/”
SUPPORT_URL=”https://www.debian.org/support”
BUG_REPORT_URL=”https://bugs.debian.org/”

root@26a4cc3a312a:/# uname -a
Linux 26a4cc3a312a 3.10.0-1062.9.1.el7.x86_64 #1 SMP Fri Dec 6 15:49:49 UTC 2019 x86_64 GNU/Linux

Install Network Utilitis in Container

root@26a4cc3a312a:/# apt-get update
root@26a4cc3a312a:/# apt-get install iputils-ping
root@26a4cc3a312a:/# apt-get install telnet
root@26a4cc3a312a:/# apt-get install traceroute
root@26a4cc3a312a:/# apt-get install net-tools
Note: net-tools will include ifconfig command

Leave a Reply

%d bloggers like this: