I’m rather new to Docker and following along with the Docker getting started tutorial that comes after you first install Docker Desktop for Windows. It all went swimmingly until it came to docker-compose section where I get an error I can’t get past. Here is the docker compose I created based on the instructions:
version: "3.8"
services:
app:
image: node:12-alpine
command: sh -c "yarn install && yarn run dev"
ports:
-3000:3000
working_dir: /app
volumes:
-./:app
environment:
MYSQL_HOST: mysql
MYSQL_USER: root
MYSQL_PASSWORD: secret
MYSQL_DB: todos
mysql:
image: mysql:5.7
volumes:
- todo-mysql-data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: todos
volumes:
todo-mysql-data:
And here is the results:
C:\temp\app>docker compose up -d
services.app.volumes must be a list
C:\temp\app>
For volumes and ports, each list item starts with a hyphen, followed by space and then its value.
Though, your list items for the app service miss the space between the hyphen and the value.
I haven’t notice before, but the taget can’t be right like that. Its either /host/path:/container/path or volume-name:/container/path. Are your sure the error message is still the same? It shouldnt have been.
update haven’t notice that its DDfW: I am not sure if ./ is a valid path from Powershells perspective either. Though I assume you ment - .:/app instead of - ./:app. I have no idea how to get the current path in a compose file on windows.
Ahhh Thanks you. I swear I know how to read, I just fail to read sometimes
OK making progress. Now it is having problem with the path I provided. Must the path be hard coded to a specific absolute path? That seems to have some portability issues, which seems to counter to the idea of docker being highly portable.
C:\temp\app>docker compose up -d
[+] Running 3/4
- Network app_default Created 0.1s
- Volume "app_todo-mysql-data" Created 0.0s
- Container app-app-1 Creating 0.2s
- Container app-mysql-1 Created 0.2s
Error response from daemon: invalid volume specification: '/run/desktop/mnt/host/c/temp/app:app:rw': invalid mount config for type "bind": invalid mount path: 'app' mount path must be absolute
C:\temp\app>