You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
ASYD/ASYD_Docker/docker-02/vol_host/solution.md

34 lines
952 B

# on host, first create a directory /user/home/data
# on host, create a container with a host container in /mydata
```docker run --rm -it -v /home/pi/data/:/mydata debian```
# in container, change directory to volume
```cd /mydata```
# create the greeting
```echo "hi" > greetings.txt```
# show created file
```ls -l```
# output content of created file to console
```cat greetings.txt```
# exit from container
```exit```
# again on the host, create another container with a named container in /stillmydata
```cd /home/pi/data/```
# show greetings-file in volume
```cat greetings.txt```
# need to change permissions before writing to file
```sudo chmod o+w greeting.txt```
```echo " bye" >> greetings.txt```
# exit from container
```cat greetings.txt```
# create a new container with a host container in /mydata
```docker run --rm -it -v /home/pi/data/:/stillmydata debian```
# show greetings-file in volume
```cat /stillmydata/greetings.txt```