Docker Community Forums

Share and learn in the Docker community.

Commit container, stop and run


(Amalmberg) #1

Hi,
I am trying to learn some basic Docker (v 1.8.1) usage. I have 2 containers, one runs Tomcat and one runs Jenkins both created from Docker prebuilt containers.

Using Tomcat I can run the commands:
$docker commit <container_id> tomcat1
$docker stop <container_id>
$docker run –p 8888:8080 tomcat1 (the -p to expose it external to my laptop)

This works perfect, all changes to tomcat1 is preserved.

trying to do the same on my Jenkins container:
$docker commit <container_id> jenkins1
$docker stop <container_id>
$docker run –p 32769:8080 –p 32768:50000 jenkins1

This does not work :frowning: no changes to jenkins1 is preserved and my jenkins jobs are gone. It seems to reload the basic/initial container each time.


(Joe) #2

Hi,

docker commit and docker stop require as input a Container ID, while docker run will require as input an Image ID.

docker commit will update the Image, with the changes made to the Container. And to instantiate a new Container from this updated Image, you will have to mention that Image name to the docker run command.

Could you re-run the commands, with this understanding and see what you get?

Cheers,
Joe


(Amalmberg) #3

Hi Joe,

thanks. I followed your instructions, and yes it worked. I am quite sure I did that yesterday as well, the COMMIT and STOP commands did have a Container Id (forgot them in my first input). I confirmed by adding a dummy file in the file system in the containers, and the file was still there after COMMIT, STOP and RUN :smile:
Problem was that yesterday I only looked in Jenkins, and discovered that my jobs where gone, never checked in the container itself, that’s why I thought the COMMIT did not work.
Have the same problem today, the Jenkins jobs are gone, but now I know that the COMMIT cmd works.
Thanks!