[Docker] Download content from the Docker image to the local

Use the docker run command to start the image and enter the container.

docker run -it --name my-container my-image:tag /bin/bash

Where my-container is the name you give the container.

Perform desired operations in the container, such as downloading files into the container.

Use the docker cp command to copy the files in the container to the local.

docker cp my-container:/path/to/file /local/path

Where /path/to/file is the file path to be copied in the container, and /local/path is the local path.

Upload content from local to Docker container:
Use the docker cp command to copy local files into the container.

docker cp /local/path my-container:/path/to/file

Where /local/path is the local file path, my-container is the container name, and /path/to/file is the target path to be copied in the container.

Perform desired operations in the container, such as unzipping files or installing software.

Use the docker commit command to save the modified container as a new image.

docker commit my-container my-image:tag

Where my-image:tag is the new image name and version number.

Guess you like

Origin blog.csdn.net/weixin_47665864/article/details/130090617