Docker: Difference between revisions
From artserver wiki
No edit summary |
m (Text replacement - "Code_Notes" to "Code Notes") Tag: Manual revert |
||
(2 intermediate revisions by the same user not shown) | |||
Line 25: | Line 25: | ||
==Persistent Storage with host Volumes== | ==Persistent Storage with host Volumes== | ||
===with local dir=== | |||
sudo docker run --rm --name calculator_api -v /local/dir/:/persistent/dir/in/container calculator_api:latest | sudo docker run --rm --name calculator_api -v /local/dir/:/persistent/dir/in/container calculator_api:latest | ||
Line 39: | Line 39: | ||
The persistent dir in the container will be mounted to a volume inside /var/lib/docker/volumes/ | The persistent dir in the container will be mounted to a volume inside /var/lib/docker/volumes/ | ||
==Other operations== | |||
===Copy file from local system to docker container=== | |||
sudo docker cp localfile continerid:/destination/of/file | |||
[[Section::Code Notes]] | [[Section::Code Notes]] | ||
[[Date::2020]] | [[Date::2020]] |
Latest revision as of 13:53, 25 August 2022
build
sudo docker build -t calculator_api:latest .
Load image file into local docker images repository
sudo docker load -i calculator_api.tar
Run container
sudo docker run --rm -p 6543:6543 --name calculator_api calculator_api:latest
Enter running container
sudo docker run --rm -it --entrypoint=/bin/sh calculator_api:latest
save to image
sudo docker save calculator_api:latest | gzip > calculator_api.tar.gz
Shutdown the docker container gracefully:
sudo docker stop calculator_api
Persistent Storage with host Volumes
with local dir
sudo docker run --rm --name calculator_api -v /local/dir/:/persistent/dir/in/container calculator_api:latest
with docker volume
sudo docker volume create volume_name sudo docker volume ls sudo docker volume inspect volume_name sudo ls /var/lib/docker/volumes/wiki_imgs/_data build image sudo docker run --rm --name calculator_api -v volume_name:/persistent/dir/in/container calculator_api:latest
The persistent dir in the container will be mounted to a volume inside /var/lib/docker/volumes/
Other operations
Copy file from local system to docker container
sudo docker cp localfile continerid:/destination/of/file
Code Notes 2020