I would like to know how I can – essentailly – mount a docker dir so I can see the files in my file manager and all changes that I make are then present in the docker image. Do I need to install an ssh sever on the docker image and sshfs into it? This seems overly complicated and by the lack of ssh servers I think there has to be a better way.
I am following the documentation found here:
https://hub.docker.com/_/wordpress/
Sadly this documentation is severely lacking (actually like all docker documentation that I found).
I guess it has something to do with the volumes, but I cannot figure out how they work.
Thanks for any help!
docker-compose file:
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8080:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: exampleuser
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: exampledb
volumes:
- wordpress:/var/www/html
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- db:/var/lib/mysql
volumes:
wordpress:
db:
2
Answers
create the directories "wordpress" and "db" on the same level as the docker-compose.yml.
enter the following in the docker-compose.yml file (notice the "./" under the volumes and the omittance of the "volume:" stuff at the end):
start docker and run "$ docker-compose up" and you will find that the directories you have created contain the files from the docker image.
You can bind a directory from the your machine to the container using the volume flag and following the pattern
/your/machine/path:/container/path/
for example
You can view
/host/project_folder
in a file browser will be the same as/container/project
. Any changes you make to in this directory will be reflected in the container as well, while it is running. Note that no changes you make in this folder will be persistent