简体   繁体   中英

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.

I have found a similar question here but it did not solve my problem.

This is my Docker file:

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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