Update a running container

I created a linux docker container I want to be able to access on my local network as well as from the internet. I setup a macvlan network and assigned it an IP address from my local network.

I forgot to setup the hostname. The hostname in /etc/hostname is an image number.

Can I use docker service update with the hostname and image option? Also, while doing this, I may as well set the DNS while I’m at it.

I’m new to this and don’t want to break things.

docker service update --image=ubuntu --hostname=ubuntu --dns="" --dns=""

Not sure if the = or " " are needed.

Any help would be appreciated. I can rm the image and start over but if this would work, it would save me a little time.


docker service update is to update Docker Swarm services. It is always better to use a configuration file like docker-compose.yml for Docker Compose. You can even use that for Docker Swarm stack, except that the supported parameters can be different. Then you can run just docker compose up -d as many times as you whish and it will recreate the container.

You can’t change a running container. You could exec into the container and change some files but that is absolutely not recommended. Even with Docker Compose your old container will be stopped and a new one will be started. If you can’t allow even that much downtime, you need multiple instance of your service in a Docker Swarm cluster or in Kubernetes, and you also need a load balancer. That is not for small services visiteed by a small audience.

Thanks!! I did see something about Docker swarm but I don’t have 3 PCs running linux to set it up.

Guess I’ll just delete the container and start over.


You actually don’t need three computers. You can initialize it on one and use it as a manager and a worker too. Only if you want to, but I would use Docker Compose instead.

I already started over. Its downloading the files now. I will look into trying to set that up. I have a Win10 running docker with Ubuntu installed also just not 3 separate PCs.

I got rancher setup but I can’t seem to add any hosts. Think it has to do something about it running on the same machine as the host.

As far as I know, Rancher uses Kubernetes, not Docker Swarm. Bot of the orchestrators requires communication between the nodes, which can be tricky with Docker Desktop on Windows. If you have a full virtual machine and you can configure the network correctly, it doesn’t matter how many physical host you are using.

1 Like

Rancher provides a management UX for K8s clusters as well as tooling to create clusters and pods (groups of one or more containers) running on them. The Rancher management tooling does not need to run within K8s itself, you can run it as a stand-alone docker container, on bare metal, or in K8s. Many people who don’t need full HA for Rancher itself (even if they do for K8s master and worker nodes) will just run a single rancher container. In previous versions (1.x) Rancher supported its own cluster orchestration (cattle) and Docker swarm, but these days only K8s AFAIK.

Whilst the OP mentioned K8s, I don’t get the impression that they have a full understanding of how it differs from Docker Swarm and/or the requisite skills to create and manage K8s clusters. That said, for an easy learning experience as well as one that doesn’t require multiple hosts (VMs or physical machines) I would recommend either k3d or kind (master and worker nodes are created as docker containers). Rancher supports importing K8s clusters from either. With this environment you have a complete working K8s lab including HA support, as well as one which is disposable. So for rapidly creating and tearing down clusters especially for learning, its ideal IMHO.

As far as managing docker container configuration without the need for more sophisticated orchestration capabilities, I agree with you that docker-compose is the way to go.



The thread came on long way from “I want to update a running container” to single or multinode kubernetes. Static ip addresses (regardless whether macvlan or something else) is not possible with swarm services, so better don’t bother with swarm if static ip’s are a must.

@thomasdukes Containers are ment to be ephemeral/disposable. In order to not lose file state, you need to map volumes or bind-mounts into the folders that hold the state. I can imagine that docker compose might be sufficient for your needs. You should make yourself aquinted with it, as it makes life way easier when it comes to reproducable deployments or configuration changes.