Building Docker Images: Copy and Commit

In order to copy to a container you need to:

  1. Find the container ID
    1. Open PowerShell window
    2. run the following command: docker ps
    3. Take a note of CONTAINER ID
  2. Stop the container
  3. Copy a file to the container using docker CP Command. Eg:
    docker cp xxxxxxxxxxx:c:/testfile.txt c:/inetpub/wwwroot/
  4. See docker cp for more info

In order to commit the container:

  1. Run the docker commit command. Eg:
    docker commit xxxxxxxxxxx my-image-name:my-tag
  2. See docker commit for more info

Note: You should only use this method to test minor changes to an image. If you are building a final image you should minimize the number of changes (i.e. copies or commands) you make as this adds extra layers. Rather than this, you should copy all files on to base image in one transaction.

Leave a Reply

Your email address will not be published. Required fields are marked *