Docker组合问题:找不到容器命令 [英] Issue with docker compose: container command not found

查看:357
本文介绍了Docker组合问题:找不到容器命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试使用docker-compose启动多个容器时遇到问题:



Dockerfile:

  FROM nginx:1.9 
添加./nginx-sites/default / etc / nginx / sites-available / default
pre>

docker-compose.yml:

 版本:2 
services:
web:
build:。
ports:
- 80:80
volumes:
- ./src:/var/www
links:
- fpm
fpm:
image:php:7-fpm
卷:
- ./src:/var/www

当我使用 docker-compise up 启动应用程序时,我收到以下错误:

 错误:未找到或不存在容器命令。 

想要解决这个问题的一些帮助。

解决方案

像原始问题的评论中提到的 php:fpm 图像要求将卷设置为 / var / www / html



如果要使用其他目录,可以使用自己的Dockerfile(基于php:fpm )。 Dockerfile 会这样:

  FROM php:fpm 

WORKDIR / var / www

好像将工作区设置为所需的目录这个窍门。



然后在您的 docker-compose.yml 中,您将使用该Dockerfile构建而不是使用php :fpm image直接。

 版本:2
服务:
#...
fpm:
build:./path/to/dockerfile
卷:
- ./src:/var/www


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 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

这篇关于Docker组合问题:找不到容器命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆