Navigate back to the homepage

learning docker - day 4

Christos Paschalidis
December 17th, 2020 · 1 min read

container lifetime & persistent data

when there is the need to store data like databases etc we use something called Volumes. Now you can create volumes while you writing your Dockerfile and that basically means that you will allocate some space outside of the container and this will be persistent even when you delete the container itself. Volumes need manual removal and they can only be destroyed by an extra step.

*** TIP: Volumes can be defined in the Dockerfile

inspect image metadata.

will give you the metadata of the image.

1docker image inspect mysql

list the volumes

1docker volume ls

created images with named volumes

you can do so by passing the -v argument in the container creation

1docker container run -d --name mysql-named -e MYSQL_ALLOW_EMPTY_PASSWORD=True -v mysql-db:/var/lib/mysql mysql

inspect named volumes

1docker volume inspect mysql-named

create a volume ahead of time

1docker volume create --help

bind mounting

is just a mapping of the files in the host file/directory into the file/directory of the container

Cant be defined in the docker file you can only do that when you do docker run . . .

view logs of container

1docker container logs -f <containerName>

More articles from blog for tech

learning docker - day 3

Docker commands I learned today

December 16th, 2020 · 1 min read

learning docker - day 2

Docker commands I learned today

December 15th, 2020 · 1 min read
© 2020–2021 blog for tech
Link to $ to $