Actions

Difference between revisions of "Docker"

From /oooooooooo.io/

Line 23: Line 23:
 
<code>sudo docker stop calculator_api</code>
 
<code>sudo docker stop calculator_api</code>
  
 +
==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</code>
 +
 +
 +
=== 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</code>
 +
 +
The persistent dir in the container will be mounted to a volume inside  /var/lib/docker/volumes/
  
 
[[Section::Code Notes]]
 
[[Section::Code Notes]]
 
[[Date::2020]]
 
[[Date::2020]]

Revision as of 17:54, 23 February 2020

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/

Code Notes 2020

... more about "Docker"
Code Notes +
Date"Date" is a type and predefined property provided by Semantic MediaWiki to represent date values.
2020 +