3

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?

5
  • @PanagiotisKanavos doesn't command in compose just run that on the container? not on the host? docs.docker.com/compose/compose-file/#command Commented Jun 21, 2016 at 14:03
  • For what it's worth, I spun this up on linux and didn't have any trouble getting /bin/sh to work there. My test stopped short since I don't have a valid package.json. Commented Jun 23, 2016 at 20:01
  • @BMitch thanks for the attempt! I have it working fine on linux also, its so annoying why windows wont play nice :( and if it complains theres no package.json its getting further than I do Commented Jun 23, 2016 at 20:32
  • @Horse are you using docker-compose from Windows directly, or from the docker-machine VM through an ssh session? Commented Jun 23, 2016 at 22:04
  • 1
    @VonC directly from the docker windows terminal, I will try and ssh in and try it from the docker-machine instead later, see if there is any difference Commented Jun 24, 2016 at 10:44

2 Answers 2

1
+50

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.

Sign up to request clarification or add additional context in comments.

2 Comments

OK nice one, thanks for checking it! :) I am still on W7, and think new docker for windows is W10 only (boooo! :P), but I will have a play asap and then accept this answer
Had a play yesterday and ended up just installing a Linux distro onto virtualbox, then installing docker directly onto that. Native docker on W7 is just not playing nice, and perfectly fine being ssh'd into a bridged vbox. I find it kind of hilarious that this is what docker for windows does anyways and its still not doing it right but whatever, thanks for your answer and confirmation it works on new docker. Just a shame that this is W10 only. Accepting your answer :)
0

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

6 Comments

Thanks for the input, but I think there it is referencing the main docker run. Prepending it with run just gives me Container command 'run' not found or does not exist.
the docker-compose command in the yml file, should execute that command on the container? eg - docs.docker.com/compose/compose-file/#command
Then it's weird. The install may be broken.
And I mean, the container itself may be broken. If it exists, then it may not be in PATH (give abs. path)
thanks for the input @paul-stelian but as mentioned in OP, already tried that :( Its really odd. I have recreated the container from scratch a couple of times.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.