I've created a container from ubuntu:latest
image. For this I've created this docker-compose.yml
:
version: '2'
services:
test_port:
image: ubuntu:latest
container_name: test_port
tty: true
privileged: true
Now I enter into container with docker exec -it <test_port_id> bash
and I do some work into. Suddenly I realize that I need bind ports with host port, so I stop the container and I add the port
section to my docker-compose.yml
like this:
version: '2'
services:
test_port:
image: ubuntu:latest
container_name: test_port
tty: true
privileged: true
ports:
- "12345:12345"
If now I run docker-compose up
again, Docker recreates container test_port
, giving it a new ID, this is, Docker create a new container and I lose all my work done in test_port
.
My question is: is there any way to bind ports (or make changes in general) in existing container from docker-compose.yml
without recreating container but changes taking effect?
EDIT: Creating an image from container is not an option. Original problem has volume
section for time synchronization (npt
) and if I construct a new container from this image it throws an error because of this.
Thanks in advance!