简体   繁体   中英

docker-compose on Windows - Container command 'sh' not found or does not exist

Having some odd issues getting docker to behave on a windows host, but on a linux host its fine. Its just a simple node container that can run gulp (and will eventually be attached to other LAMP like containers).

my docker-compose.yml

version: '2'
services:
 node:
  build: ./node
  container_name: cont_node
  ports:
  - "35733:35733"
  volumes:
  - ~/docker/project/www:/var/www/html/
  command: "sh -c 'npm install && bower install && gulp'"

my Dockerfile

FROM node:4-onbuild

RUN npm config set registry http://registry.npmjs.org/

# Define working directory.
WORKDIR /var/www/html/

COPY ./package.json /var/www/html/

RUN npm install -g gulp-cli

CMD ["bash"]

so when I run

docker-compose up node

it returns

Container command 'sh' not found or does not exist.

Being that I understood the command command ran on the container (not the host), this should be fine? I have tried it with /bin/sh too and having the same problem. /bin/sh does exist, seems to be a sym link to dash if thats relevant? Looks identical to my linux host where this works fine.

Any ideas what is going wrong?

On a side note , anytime I use docker from a linux host it works like a dream, but windows I always lose hours wrestling with windows specific issues, npm installs dont seem to work properly or hang or take ages, issues with volumes not in my documents, etc. Is docker on windows / boot2docker fubar'ed or just me?

Runs fine for me on Windows 10 and Docker for Windows beta. I'd say either a outdated Docker setup or something is borked on your machine. If you are still running boot2docker try switching to Docker for Windows .

On a side note, anytime I use docker from a linux host it works like a dream, but windows I always lose hours wrestling with windows specific issues, npm installs dont seem to work properly or hang or take ages, issues with volumes not in my documents, etc. Is docker on windows / boot2docker fubar'ed or just me?

Well Windows always adds a bit of pain to almost anything :p, and in the early boot2docker days Windows support was quite buggy/incomplete, but with the latest Docker for Windows releases things are running pretty smooth now.

(posting this as answer since I don't have enough rep. to comment)

For some reason Docker attempts to run the command in the host instead of the guest. Since it says "container command" you may actually want to prepend it with "run", as in the online reference .

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