Naor
Naor

Reputation: 24093

Docker compose fails

I wrote a node server and I'd like to wrap it with docker compose for development (later I'll add more services). This is my docker-compose.yml:

version: '3'

services:
    server:
        image: node:alpine
        volumes:
            - ./
        working_dir: /.
        environment:
            NODE_ENV: development
        ports:
            - 8009:8009
        command: npm run dev

When running docker-compose up I get:

Recreating bed_server_1 ... error

ERROR: for bed_server_1  Cannot start service server: OCI runtime create failed: container_linux.go:348: starting container process caused "open /proc/self/fd: no such file or directory": unknown

ERROR: for server  Cannot start service server: OCI runtime create failed: container_linux.go:348: starting container process caused "open /proc/self/fd: no such file or directory": unknown
ERROR: Encountered errors while bringing up the project.

I am using mac. Any idea what is wrong?

Upvotes: 3

Views: 2850

Answers (2)

veben
veben

Reputation: 22332

This error may occurs because of the volume. You should try to remove these lines:

volumes:
    - ./

Then try to map the folder to a volume declared in the docker-compose file, like that:

services:
    server:
        image: node:alpine
        volumes:
            - test_volume:./
        working_dir: /.
        environment:
            NODE_ENV: development
        ports:
            - 8009:8009
        command: npm run dev
volumes:
    test_volume:
        external: true

Upvotes: 2

Bless
Bless

Reputation: 5370

The volumes should be mapped to a folder inside the container. ./ doesn't say where the folder is to be mapped inside the container. To say that, change the volumes to ./:/app to map ./ directory from host machine to /app directory inside docker and update working_dir as below:

        volumes:
            - ./:/app
        working_dir: /app

Upvotes: 1

Related Questions