Docker - Tips
Container → Image
-
Docker images
-
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE fjvallarino/pytorch-geometric latest 7ee3fe57718c 21 months ago 4.23GB
-
-
Run the docker image as a container (or we can run the image on Docker Desktop)
-
$ docker run --name container_name fjvallarino/pytorch-geometric
-
-
List running containers
-
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES cf66765c8f20 fjvallarino/pytorch-geometric:latest "/bin/bash" 2 months ago Up 8 seconds container_name
-
-
Running container → image
-
$ docker commit -a [AUTHOR] -m [COMMIT MSG] [CONTAINER NAME] [REPO]:[TAG]
-
$ docker commit -a "acousticwave" -m "commit_test" container_name acousticwave/pytorch-geometric:2022-06-11
-
-
Check the built image
-
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE acousticwave/pytorch-geometric 2022-06-11 a4cc2d1caf95 53 seconds ago 7.56GB
-
Image → Remote Repo.
- Docker Desktop can pushs the built image to a remote remote repository

- We can pull this image on other devices.

Sharing Host Path with Container Path
- Docker Desktop support sharing a
Host(Local) Path
withContainer Path
- Docker Desktop → Images → Run → Operation Settings
- Container Name: Set
Container Name
- Volumes
Host Path
: Define a path to be shared with a container (files in this path are uploaded toContainer Path
)Container Path
: Path to be connected toHost Path
- Container Name: Set
- Docker Desktop → Images → Run → Operation Settings


Attaching a Container to Visual Studio Code
- Open a Visual Studio Code window and install Docker and Remote Development extensions.
- And Run a Container (Setting of
Host Path
andContainer Path
required as explained above) - Type
Cmd + Shift + P
andremote-containers: Attach to Running Container...

- Select a running container

- VSCODE > Open Folder … > Type
Container Path

Move an Image to Other Env (TBU)
-
List Docker images
-
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE acousticwave/pytorch-geometric 2022-06-11 a4cc2d1caf95 53 seconds ago 7.56GB
-
-
Docker image → .tar file
-
docker save [OPTION] <FILENAME> [IMAGE-NAME]
-
docker save
-