Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to make container configuration changes on (running) containers #3285

Closed
jorisvddonk opened this issue Dec 19, 2013 · 49 comments
Closed
Labels
kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny

Comments

@jorisvddonk
Copy link

I'd like to be able to make configuration changes to a container (running or stopped). Specifically, any setting that can be set when starting a container with docker run should be able to be changed after-the-fact easily.

Rationale:
When working with containers, it's inevitable that at one point you find yourself in a situation where you've spent an hour fiddling with a running container so that you can start using it (e.g. setting up a job system in a Jenkins container), only to realize that you forgot to make a certain configuration change way back when you ran the container using docker run. This tends to happen a lot with badly-documented images on the Index; if the image documentation doesn't tell me that I need to expose port 443 on my host system, I'm probably going to forget that.

In such cases, it would be great if I could make container configuration changes whilst the container is running, or after I've stopped the container manually.

Unfortunately, docker doesn't currently seem to support this. Since you can't re-run a stopped container with docker run, you would need to commit the container to an image and then re-run it.

Unfortunately, docker commit clears the container's configuration, so you need to explicitly set a startup configuration using the -run commandline argument, unless you don't mind manually specifying the entrypoint/cmd et cetera each time you run this new image with docker run (which I don't think is very user friendly). As a workaround, you can inspect the container, copy the Config, and paste the config into the -run parameter of docker commit, but this isn't really user-friendly either.

@bfirsh
Copy link
Contributor

bfirsh commented Jan 17, 2014

Related to #2733. What we probably need is an "update" command that takes similar options to "run" along with a container ID/name.

@reberhardt7
Copy link

For those needing a quick fix for port mapping/binding: http://stackoverflow.com/questions/19897743/exposing-a-port-on-a-live-docker-container

@nivance
Copy link

nivance commented Jun 6, 2014

iptables can't work.

@jerng
Copy link

jerng commented Jul 27, 2014

+1(!)

@Mulkave
Copy link

Mulkave commented Sep 2, 2014

+1
Some of the things I needed most is to re-import the --env-file and --link to a newly run container without having to restart.

@muddflappz
Copy link

+100

@JasCodes
Copy link

JasCodes commented Jan 4, 2015

+1

@nazar-pc
Copy link

nazar-pc commented Jan 4, 2015

Even changing ports binding without need to create intermediate image and start new container would be great.

@pjincz
Copy link

pjincz commented Jan 5, 2015

+1

I want to change a container's base image. And keep all other settings.
It will be very very useful. When you have an new image.
But, I have to recreate container with all arguments I used.
That's very dangerous.

@thaJeztah
Copy link
Member

@jinchizhong changing the base-image of a (running) container is not possible (even if this proposal is implemented). This proposal is only for changing a limited number of settings of a running container (for example, rename the container, expose/publish ports, add a link to a container)

@JasCodes
Copy link

JasCodes commented Jan 6, 2015

@thaJeztah Would also like to have a flag while commit to copy settings of running container and bake it to image

@o0x2a
Copy link

o0x2a commented Jan 18, 2015

+1
Need to add new volume and publish new ports after running a container

@windlessuser
Copy link

+1
Common guy's it's been 2 years. It is a real pain when trying to setup a group of containers that need to talk to each other.

@IanWizard
Copy link

I think it's safe to stop with the +1s. I too find myself wanting this almost daily, but am some how able to divine the strength and serenity to not pollute the internet with yet another +1. There's no doubt it's a desired and useful feature. If you're not contributing to the conversation, please keep it to yourself.

@Mulkave
Copy link

Mulkave commented Feb 4, 2015

@IanWizard totally agree, the Subscribe button is right there for this specific reason.

@toby-griffiths
Copy link

Thank you @IanWizard Was getting a little frustrated with all the email (he says, triggering another one)

@jessfraz jessfraz added kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny and removed Orchestration labels Feb 26, 2015
@IanWizard
Copy link

I will slap the next person to +1 this...

@nijikokun
Copy link

+1....

@isanych
Copy link

isanych commented May 13, 2015

container renaming would be nice

@cpuguy83
Copy link
Member

@isanych container renaming was introduced in docker 1.5

@isanych
Copy link

isanych commented May 13, 2015

@cpuguy83, thanks, will ask to upgrade docker on server

@keshy
Copy link

keshy commented May 14, 2015

+1!!

@sinchb
Copy link

sinchb commented Jul 13, 2015

+1

@IanWizard
Copy link

Even the political threads don't hurt this much.

On 07/29/2015 11:24 AM, Charles Ferreira Gonçalves wrote:

+1


Reply to this email directly or view it on GitHub
#3285 (comment).

@charlesfg
Copy link

I agree with @bradleypeabody .... The requirement of 'running' could be removed if this would make the implementation easier. Would not be a great deal to stop the container.

@cnaize
Copy link

cnaize commented Aug 31, 2015

Hello!
What about progress in this issue?
Can I help to implement this?

@cpuguy83
Copy link
Member

There is an implementation here: #15078

@f3l1x
Copy link

f3l1x commented Nov 14, 2015

👍

@GordonTheTurtle
Copy link

USER POLL

The best way to get notified when there are changes in this discussion is by clicking the Subscribe button in the top right.

The people listed below have appreciated your meaningfull discussion with a random +1:

@lamersons
@Jas99
@wufeifei
@grubin1989
@kunalkushwaha
@lifei
@ds82
@edoardoo
@andergmartins
@mahmoudimus
@mbejda
@aryounce
@dpavlos
@toby-griffiths
@brandongalbraith
@miroslav-beranic
@anvaughan
@charlesfg
@sirvon
@nazar-pc
@lhoss
@oneasteriskone
@ngnmnfn
@acollign
@reduardo7
@haseebq
@buptwangzhe
@cxshun
@ourway
@TTimo
@scarletsky
@thefosk
@ierceg
@fizzy33
@baptistedonaux
@MarcEtienneDery
@njd5475
@MBEntwicklung
@elephantum
@coder-chenzhi
@oodograss
@eranchetz
@prafulrana
@JasonGhent
@sanben94
@sspreitzer
@e-dorigatti
@rloomba
@chrislim2888
@kwando
@reberhardt7
@nsavch
@blackfader
@simonrajan
@adrianlzt
@osharav
@dhilipkumars

@omerh
Copy link

omerh commented Feb 10, 2016

+1
This command will be great: docker remove -p 443:443 container_id

@cpuguy83
Copy link
Member

@omerh see docker update command in docker 1.10
It currently only supports modifying container resource constraints.
I'm not sure it will be expanded to support changing exposed ports... probably best to open as a specific issue.

I believe we should close this generic issue since docker update exists now for this purpose and anything it doesn't specifically support yet should be opened as separate issues.

ping @thaJeztah Do you agree?

@thaJeztah
Copy link
Member

I agree, each property that's added to docker update should be looked at separately, so there's no reason to keep a "general" issue open now that docker update is there.

@carloscarcamo
Copy link

+1

@b1zzu
Copy link

b1zzu commented Jan 28, 2017

+1

@p0liper
Copy link

p0liper commented Feb 9, 2017

+1
Are you think this configuration commands will enough for make changes?
I would like to change volume settings (such as "-v" arg), but I doesn't find it.
For make this change, I will create new persistent container, move all volumes to new container, and remove old.

Usage: docker update CONTAINER [CONTAINER...]

Update configuration of one or more containers

--blkio-weight Block IO (relative weight), between 10 and 1000
-c, --cpu-shares CPU shares (relative weight)
--cpu-period Limit CPU CFS (Completely Fair Scheduler) period
--cpu-quota Limit CPU CFS (Completely Fair Scheduler) quota
--cpuset-cpus CPUs in which to allow execution (0-3, 0,1)
--cpuset-mems MEMs in which to allow execution (0-3, 0,1)
--help Print usage
--kernel-memory Kernel memory limit
-m, --memory Memory limit
--memory-reservation Memory soft limit
--memory-swap Swap limit equal to memory plus swap: '-1' to enable unlimited swap
--restart Restart policy to apply when a container exits

Addressed for @cpuguy83 also for all Docker contributors. I think you fix this. Thanks :)

@thaJeztah
Copy link
Member

@yanislavb no -v is not supported on docker update. See my comment before this issue was closed; #3285 (comment)

w.r.t -v, chances are little that that would be implemented; swapping a volume in a container, at runtime can have quite some side-effects, and creating a new container with a new volume / different volume is likely the best approach.

@p0liper
Copy link

p0liper commented Feb 10, 2017

Can I modify container configuration file?
If yes, where are these files located?

@thaJeztah
Copy link
Member

The container configuration file is in /var/lib/docker/containers/<container-id>, but I discourage editing those, as they are really designed as "internal" to docker. Updating the configuration will have no effect on a running container, and not sure what'll happen after updating those files.

If your container itself does not contain any stateful data, replacing a container is really the way to go (instead of updating the existing one).

@p0liper
Copy link

p0liper commented Feb 11, 2017

On my way, that's not really

@ngtuna
Copy link

ngtuna commented Feb 28, 2017

Hi there, I am curious if we can support docker update command to update the mapped ports to the running container. That would be really helpful.

@thaJeztah
Copy link
Member

@ngtuna see #21282

@thaJeztah
Copy link
Member

I am going to lock the conversation on this issue, to repeat my earlier comment #3285 (comment);

A docker update command has been implemented, but additional options that can be updated on a running container should be looked at separately. If you think something should be added to the docker update command, please open a separate issue if it doesn't exist, and explain the use case (this is important to understand the reason why it's needed, and recreating the container is not an option).

Also note that docker services (in swarm mode) allow you to update service definitions, but mechanics are slightly different, because updating a service recreates containers.

@moby moby locked and limited conversation to collaborators Feb 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny
Projects
None yet
Development

No branches or pull requests