码头工人-compose.yml
version: '3'
services:
db:
image: "mysql"
environment:
MYSQL_ROOT_PASSWORD: "1234"
ports:
- "3306:3306"
volumes:
- .\mysql:/var/lib/mysql
php:
image: "php:7.4-fpm"
restart: always
links:
- db
nginx:
image: "nginx"
env_file:
- ./conf.env
depends_on:
- php
- db
volumes:
- D:\Михаил\homework:/var/www
ports:
- "8080:80"
- "9000:9000"
WINDOWS 8.1 专业系统
D:\Михаил\homework\docker>docker-compose exec nginx /bin/bash
root@77f231a5127d:/# cd /var/www && ls -la
total 8
drwxrwxrwx 3 root root 60 Oct 28 11:29 .
drwxr-xr-x 1 root root 4096 Oct 28 11:37 ..
drwxrwxrwx 3 root root 60 Oct 28 11:29 docker
root@77f231a5127d:/var/www#
我希望在那里看到我在本地机器上的文件夹
但不是文件和文件夹,而是只有一个文件夹docker
,其中嵌套了一个文件夹,甚至没有文件。我试图做的事情:
D:\Михаил\homework
以各种可能的方式使用转义斜杠和反斜杠更改文件夹的路径尝试使用相对路径
我求助于各种论坛, 包括这个
docker-machine rm 默认 && docker-machine create --driver "virtualbox" --virtualbox-boot2docker-url https://github.com/boot2docker/boot2docker/releases/download/v18.09.8/boot2docker.iso默认
每次尝试或更改后,我都会执行命令
docker-compose down && docker-compose up -d --build
我是码头工人的新手
D:\Михаил\homework\docker>docker-compose up -d --build
Creating network "docker_default" with the default driver
Creating docker_db_1 ... done
Creating docker_php_1 ... done
Creating docker_nginx_1 ... done
D:\Михаил\homework\docker>docker-compose logs nginx
Attaching to docker_nginx_1
nginx_1 | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
nginx_1 | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
nginx_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
nginx_1 | 10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf
nginx_1 | 10-listen-on-ipv6-by-default.sh: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
nginx_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
nginx_1 | /docker-entrypoint.sh: Configuration complete; ready for start up
D:\Михаил\homework\docker>
告诉我需要做什么,这样通过进入docker-compose exec nginx /bin/bash
并执行里面的命令,cd /var/www && ls -la
我可以在那里看到我的工作子目录D:\Михаил\homework
该路径
D:\Михаил\homework
肯定行不通,因为它是主机系统上的路径。您必须首先使该文件夹在虚拟机中可用。那些。在虚拟机中,沿着某个路径挂载一个文件夹,比如
/mounted_win_drive
,并且已经在虚拟机中使用该文件夹作为 docker 中的卷。一步一步做。
docker run -v /mounted_win_drive:/data nginx ls /data
docker-compose