Skip to content

docker_repeat

M1chaelM edited this page Dec 2, 2020 · 6 revisions

Repeat

Now that you have modified your container and committed your changes to a new image, you can repeat this process to continue to improve your system until it is ready to submit.

To pick up where you left off before committing changes, run:

docker run -it --name my_container_2 <USERNAME>/<IMAGE_REPOSITORY_NAME>:<TAG>

where the values of <USERNAME>, <IMAGE_REPOSITORY_NAME> and <TAG> should match what you used when you ran the commit command.

Notes:

  • Docker will not allow you to re-use an image name (i.e. my_container) without first deleting the original. There are more sophisticated ways around this but for simplicity we are just using a different name each time.
  • You'll notice your container is now running the script we created, and killing the script will cause the container to exit.
  • To override the entry point and start an interactive bash session instead, run:
docker run -it --name <CONTAINER_NAME> --entrypoint bash <USERNAME>/<IMAGE_REPOSITORY_NAME>:<TAG>

where <CONTAINER_NAME> can be any name of your choosing.

Starting a new interactive Bash session

It is often useful to be able to open a new Bash session into a running container. To do this:

  • Leave the container running and open a new terminal.
  • Run
docker exec -it <CONTAINER_NAME> bash
  • You should now have a new bash session inside your container.
  • You can repeat this command to open new sessions as needed.
  • Note that closing the original session will also close all attached sessions.

Wrapping Up

When your solution is ready to submit and has been committed to the local image, the last step before submitting is to upload it to your DockerHub repository.

Previous: Commit Changes Up: Development Process Overview
Clone this wiki locally