Sharing a Folder¶
When you share a folder the base operating system and the running containers will be able to see and consume the files inside it. This is one option for the host machine and the container to interact.
In the section, “Copy the Configuration File using Dockerfile”, you created and copied the configuration file to
the /home/shellhttpd/
folder. Purposefully leave the changes you just did because
you will share the same folder to see what happens.
Edit the docker-compose.yml
file adding the volumes
stanza:
shellhttpd/docker-compose.yml:
Above, you add the volumes:
stanza with the value
/var/rootdirs/home/fio/shellhttpd:/home/shellhttpd/
.
This means that the /var/rootdirs/home/fio/shellhttpd
folder from your host machine
will be mounted over the container’s /home/shellhttpd
folder.
The container folder content will be overwritten by the host machine folder content.
Thus, as the host machine folder is empty, the shellhttpd.conf
you copied in the
Dockerfile
will disappear in this new setup.
Check your changes, add, commit and push to the server:
Make sure you received your update by checking the latest Target on the Devices tab in your Factory.
Open one terminal connected to your device and check the running containers:
Example Output:
Monitor the docker logs:
Example Output:
Open a second terminal connected to your device and check for the
/var/rootdirs/home/fio/shellhttpd
folder:
The folder is empty and was automatically created when the Docker image was launched. Let’s create a new configuration file inside that folder and follow the logs from the first terminal:
And in the first terminal you should see the new MSG
value:
Example Output:
Just to confirm the change, test the container from an external device connected to the same network (e.g. your host machine: the same computer you use to access your device with ssh).
Example Output:
At this point, you learned how to share a folder with the Docker container and how to manually update the configuration while the container is running.