6

I created a docker container, and then I created a file and exited the container.

When I restart the container with:

docker run -i -t ubuntu /bin/bash

the file is nowhere to be found. I checked /var/lib/docker/ and there is another folder created which has my file in it. I know it's something to do with Union FS.

  1. How do I start the same container again with my file in it?
  2. How do I export a container with file change?

1 Answer 1

5

I don't know if this will answer your question completely, but...

Doing docker run -i -t ubuntu /bin/bash will not restart any container. Instead, it will create and start a new container based on the ubuntu image.

If you started a container and stopped it you can use docker start ${CONTAINER_ID}. If you did not stop it yet you can use restart.

You can also commit (export) the container to a new image: see http://docs.docker.io/en/latest/commandline/command/commit/ for the correct syntax. docker export is a option as well, but all that will do is archive your container. By creating a new image using docker commit you can create multiple instances (containers) of it afterwards, all having your file in it.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the quick reply this makes sense. I have a few queries.. 1) how do you find container ids 2. how do i get back to bash when i do docker start
Please also try to find out stuff yourself :) 1) stackoverflow.com/questions/16840409/… 2) docker attach
Btw. if Union FS did not have anything to do with your question (with you new info) please update the question, and if you actually use the posted answer, select it so people know what actually answered your question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.