edit autostart command of portainer


In short my portainer container has no access to the internet, I have to pass --dns= argument to docker run so
docker run -d -p 9002:9000 --name=portainer --restart=always --dns= -v /run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce

To do that now I had to stop it and delete it. Is there a way to modify the autostart command? I dug out command above from dietpi-software file on git but I have no clue where to find autostart.

Also on kinda related note - when I was running postgres in the container I had segmentation faults on startup. Had to do this https://github.com/docker-library/redis/issues/269#issuecomment-778588162 and restart rpi.


this is something inside docker themselves and has nothing to do with DietPi because Docker is managing all the start option on your container.

Changing configuration on a running container is most likely not possible. Dropping the container and create a new one is an option and can be archived from inside portainer as well. Once a container was selected, you could Duplicate/Edit the container. This will basically create a new one and you would need to adjust settings like name, port and dns. As well you would need to do it each time you update portainer using dietpi-software

Another option is to change docker configuration globally and adjust settings inside /etc/docker/daemon.json. You would need to add DNS config like this

    "data-root": "/mnt/dietpi_userdata/docker-data",
    "log-driver": "journald",
    "log-level": "warn",
    "dns": [""],
    "debug": false

Once docker was restarted, this would have an impact on all running container.

To verify, you would need to find our your container ID for portainer docker ps -a

root@DietPiProd:~# docker ps -a
CONTAINER ID   IMAGE                    COMMAND                  CREATED       STATUS          PORTS                              NAMES
71365064d368   portainer/portainer-ce   "/portainer"             2 weeks ago   Up 14 minutes   8000/tcp,>9000/tcp   portainer
88aa508455be   dietpi/proxy             "docker-entrypoint.s…"   7 weeks ago   Up 14 minutes>3000/tcp             OneDrive-proxy

On this example, portaioner ID is starting 71365064d368

cd /mnt/dietpi_userdata/docker-data/containers/
ls -la

now you see all container

root@DietPiProd:/mnt/dietpi_userdata/docker-data/containers# ls -la
total 16
drwx-----x  4 root root 4096 Mar  4 00:40 .
drwx--x--x 13 root root 4096 Mar  4 01:36 ..
drwx-----x  4 root root 4096 Mar  4 01:36 71365064d368363a604ec4f828ef582f56cbfdce53d7228bf317ef0a50a72cd6
drwx------  4 root root 4096 Mar  4 01:36 88aa508455be9dc4ccd5e4425e607101a4daab9452e7435573539ca3099ec0ba

Go inside the container fitting portainer ID

cd 71365064d368363a604ec4f828ef582f56cbfdce53d7228bf317ef0a50a72cd6/
ls -la

There you have DNS config file resolv.conf. It should contain the new global DNS config

cat resolv.conf

BTW: if there is no DNS configure, Docker will always use the DNS server configured on the host running Docker enginge :wink:

Install portainer

It allows you to see all the settings for the container, usually if it’s not changed it usually setups a “bridged” network and ends up being completely different from your home network subnet

It also gives you a webgui to configure and control the containers…it takes a bit getting used to but it allows many options for changing and managing your containers


Many thanks for the exhausting answer :slight_smile: I’ve read about deamon.json and tried to add dns with dockerd --dns but the command didn’t work. It simply hangs. Should have just edited the json directly. Adding manually works fine, thanks!

I was playing around with deamon.json to find correct syntax. The line to add would be

    "dns": [""],