Operating System | Tool |
---|---|
Ubuntu Server 22.04 LTS |
Docker version 20.10.25, build 20.10.25-0ubuntu1~23.04.1 , Portainer 2.18 |
Ubuntu Server 23.04 |
Docker version 20.10.25, build 20.10.25-0ubuntu1~23.04.1 , Portainer 2.18 |
To configure the MTU properly, use Docker from apt
instead of snap
.
If you have already installed Docker through the system installation, remove the snap version of Docker first. Otherwise, skip this step.
Remove snap version of Docker:
sudo snap remove docker
Install Docker using apt:
sudo apt install docker.io
To specify/override the MTU for Docker, add a parameter to the Docker launch script. The file to edit is /lib/systemd/system/docker.service
.
If you're unsure which is the correct file, you can find it using the following command:
sudo systemctl status docker
Look for the line that starts with Loaded:
and find the path after loaded
. This is the file you're looking for.
To change the MTU setting (for example, to 1400), modify the line in /lib/systemd/system/docker.service
from:
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
to:
ExecStart=/usr/bin/dockerd --mtu 1400 -H fd:// --containerd=/run/containerd/containerd.sock
If you're using docker-compose
to launch your instances, you also need to change some configuration to ensure they launch with the specified MTU.
Your Docker Compose file should include the following section:
networks:
default:
driver: bridge
driver_opts:
com.docker.network.driver.mtu: 1400
After making these changes, restart Docker to apply the new MTU setting:
sudo systemctl daemon-reload
sudo service docker restart
If you encounter a permission error like the following when executing docker
commands:
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json": dial unix /var/run/docker.sock: connect: permission denied
You can either run docker
commands with sudo
, or enable a non-root user to access the docker
command by following these steps:
- Create the
docker
group on the system:sudo groupadd -f docker
- Add the active user to the
docker
group:sudo usermod -aG docker $USER
- Apply the group changes to the current terminal session:
newgrp docker
- Check if the
docker
group is in the list of user groups.The group should appear in the command output.groups
You should now be able to issue Docker commands as a non-root user without usingsudo
.
First, create the volume that Portainer Server will use to store its database:
docker volume create portainer_data
Then, download and install the Portainer Server container:
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
Now that the installation is complete, you can log into your Portainer Server instance by opening a web browser and going to https://localhost:9443.
Once you have accessed the Portainer Server URL, you are ready to proceed with the initial setup.
For detailed instructions on the initial setup, please refer to the official setup tutorial.
If you encounter an issue accessing the Portainer panel and see the error message shown below, it is likely because Portainer shuts down internally for security if a new installation is not configured within 5 minutes:
You can resolve this issue by running the following command to restart Portainer:
docker restart portainer