Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue with docker compose: container command not found

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.

like image 585
dev_mrsb Avatar asked Feb 14 '16 05:02

dev_mrsb


People also ask

How do I fix docker command not found?

The solution in both cases is pretty simple: install Docker using the provided tutorials for CentOS/RHEL and Ubuntu/Debian (you can also check the tutorials on Docker's Documentation website), or create a symlink in case the binary was installed in a custom location in your system.

Can I run commands from Docker Compose?

Docker Compose allows us to execute commands inside a Docker container. During the container startup, we can set any command via the command instruction.


1 Answers

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
like image 131
Alexander Blunck Avatar answered Oct 05 '22 06:10

Alexander Blunck