5

I'm having an issue when trying to start multiple containers with docker-compose:

Dockerfile:

FROM nginx:1.9
ADD ./nginx-sites/default /etc/nginx/sites-available/default

docker-compose.yml:

version: "2"
services:
  web:
    build: .
    ports:
      - "80:80"
    volumes:
      - ./src:/var/www
    links:
      - fpm
  fpm:
    image: php:7-fpm
    volumes:
      - ./src:/var/www

When I use docker-compose up to start the application, I get the following error:

ERROR: Container command not found or does not exist.

Would love some help with this issue.

6
  • I just started looking at this as I had the same problem. If you remove the volumes section from your fpm service does it start up? (obviously without the files accessible to php-fpm, but just for interests sake) Commented Feb 14, 2016 at 5:28
  • yeah. without the volumes section under fpm, it starts up normally. Commented Feb 14, 2016 at 5:55
  • 1
    actually if i set the volumes as "./src:/var/www/html" (for both web and fpm services), the application starts, but I'm not able to access anything over localhost. Commented Feb 14, 2016 at 6:14
  • Might need to hit the IP of the boot2docker vm rather than 'localhost' if you are on Mac or Windows. Mine's set to 192.168.99.100 by default. Commented Feb 14, 2016 at 6:23
  • Yup, that was it. Thanks a lot. I'm still not sure why the volume needs to be /var/ww/html, but it may be because of php-fpm. If you'll post an answer, I can mark it as accepted. Commented Feb 14, 2016 at 6:30

1 Answer 1

12

Like mentioned in the comments to the original question the php:fpm image requires for it's volume to be set to /var/www/html.

If you want to use a different dir you can work around that by using your own Dockerfile (based on php:fpm). That Dockerfile would like this:

FROM php:fpm

WORKDIR /var/www

It seems like setting the workdir to the desired dir does the trick.

Then in your docker-compose.yml you would build with that Dockerfile instead of using the php:fpm image directly.

version: "2"
services:
  # ...
  fpm:
    build: ./path/to/dockerfile
    volumes:
      - ./src:/var/www
Sign up to request clarification or add additional context in comments.

1 Comment

This should be the correct answer! The current marked answer is bogus.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.