edit autostart command of portainer Topic is solved

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Post Reply
Nightliss
Posts: 6
Joined: Fri Aug 28, 2020 9:28 am

edit autostart command of portainer

Post by Nightliss »

Hello,

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=192.168.1.1 -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 ... -778588162 and restart rpi.
User avatar
Joulinar
Posts: 5666
Joined: Sat Nov 16, 2019 12:49 am

Re: edit autostart command of portainer

Post by Joulinar »

Hi,

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

Code: Select all

{
    "data-root": "/mnt/dietpi_userdata/docker-data",
    "log-driver": "journald",
    "log-level": "warn",
    "dns": ["1.1.1.1"],
    "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

Code: Select all

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, 0.0.0.0:9002->9000/tcp   portainer
88aa508455be   dietpi/proxy             "docker-entrypoint.s…"   7 weeks ago   Up 14 minutes   0.0.0.0:3000->3000/tcp             OneDrive-proxy
root@DietPiProd:~#
On this example, portaioner ID is starting 71365064d368

Code: Select all

cd /mnt/dietpi_userdata/docker-data/containers/
ls -la
now you see all container

Code: Select all

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
root@DietPiProd:/mnt/dietpi_userdata/docker-data/containers#
Go inside the container fitting portainer ID

Code: Select all

cd 71365064d368363a604ec4f828ef582f56cbfdce53d7228bf317ef0a50a72cd6/
ls -la
There you have DNS config file resolv.conf. It should contain the new global DNS config

Code: Select all

cat resolv.conf
nameserver 1.1.1.1
BTW: if there is no DNS configure, Docker will always use the DNS server configured on the host running Docker enginge ;)
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
WarHawk
Posts: 774
Joined: Thu Jul 20, 2017 8:55 am

Re: edit autostart command of portainer

Post by WarHawk »

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
Nightliss
Posts: 6
Joined: Fri Aug 28, 2020 9:28 am

Re: edit autostart command of portainer

Post by Nightliss »

@Joulinar

Many thanks for the exhausting answer :) I've read about deamon.json and tried to add dns with dockerd --dns 192.168.1.1 but the command didn't work. It simply hangs. Should have just edited the json directly. Adding manually works fine, thanks!
User avatar
Joulinar
Posts: 5666
Joined: Sat Nov 16, 2019 12:49 am

Re: edit autostart command of portainer

Post by Joulinar »

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

Code: Select all

    "dns": ["1.1.1.1"],
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply