简体   繁体   English

在Ubuntu 18.04上运行Docker在尝试sudo docker-compose时遇到错误[/ bin / sh 1] [:missing]

[英]Running Docker on Ubuntu 18.04 getting error [/bin/sh 1] [:missing] when trying sudo docker-compose up

I am trying to create a container for a simple app that has a form in html and save the data to MongoDB using Docker but is not working. 我正在尝试为一个简单的应用程序创建一个容器,该应用程序具有html中的表单,并使用Docker将数据保存到MongoDB但不起作用。

I have found a similar question here but it did not solve my problem. 我在这里找到了类似的问题,但它没有解决我的问题。

This is my Docker file: 这是我的Docker文件:

FROM node:11
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install 
COPY . .
EXPOSE 3000
CMD [ "npm", "start"]

And my .yml file is this: 我的.yml文件是这样的:

version: "2"

services:
  app:
    container_name: docker-node-mongo
    restart: always
    build: .
    ports:
      - 8081:3000
    links:
      - mongo

  mongo: 
    container_name: mongo
    image: mongo  
    ports: 
      - 27017:27017

I was able to fix it. 我能够解决它。 Apparently, I was running another docker build which was also pulling the mongo image from docker hub. 显然,我正在运行另一个Docker构建,它也从docker hub中拉出mongo图像。 It is all working now. 现在一切正常。 So for a fix: -make sure you are not trying to build a docker image using a service that it is already in use/being pulled by another build. 因此,对于一个修复: - 确保您没有尝试使用已经在使用/被另一个构建提取的服务来构建docker镜像。 Just remove one of them to make it work using: docker rm '3ab' (the first 3 letters of the code assigned to the build) -f (force it to stop if running) and then run again docker-compose up. 只需删除其中一个使其工作使用:docker rm'3ab'(分配给构建的代码的前3个字母)-f(如果运行则强制停止)然后再次运行docker-compose up。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM