Docker Community Forums

Share and learn in the Docker community.

Is there any method I can modify the “IP” address without removing the docker container?

docker

(Nanxiao) #1

Hi all,

I posted this topic on SO originally, but unfortunately there is no response. So I repost it here, thanks.

I use docker run command to create and run a container:

docker run -p 10.10.220.52:80:8080 ubuntu bash

But suddenly, I find I use the wrong IP address. Is there any method I can modify the IP address without killing it and create a new one?


(Nathan Le Claire) #2

Not that I know of - killing and restarting a container is extremely cheap, so why not?


(Nanxiao) #3

Because I install the Oracle in my docker container. So after killing and restarting the container, the Oracle needs to be reinstalled, right? Thx!


(Timgriffiths) #4

You could hack this by using docker commit
ie. https://docs.docker.com/engine/reference/commandline/commit/

So create a new image with all your changes then recreate it with a different ip


(Nathan Le Claire) #5

@nanxiao

No, if you need to run custom software in a container (and it’s not a one-off) then you should be “baking” a Docker image using docker build (or, in a few rare cases where you need to do interactive steps that aren’t possible in a Dockerfile, docker commit might be used). Then, all of the default filesystem (including installed binaries, etc…) you expect to be available will be present on every single docker run.

Try to build an image with docker build. If you’re not baking your own images, you’re missing out on a hugely awesome part of Docker.