Docker Community Forums

Share and learn in the Docker community.

Compose attaching to mostly-empty image, but Docker not?

So I’m sure this is just a mistake I’m making … I’m new to Docker. But for the life of me I can’t figure out what I’m doing wrong.

I am using docker-compose to deploy to a set of DigitalOcean droplets a simple project to listen to an HTML stream and transfer over to an AWS server environment. So I created a set of configuration files, based on the region and type of stream the droplet is listening to:

docker-compose -f compose-de-dev.yml up validic-transfer

I’m using Docker Compose for two main features: deploy at a distance and to transfer different environment variables to each droplet to configure them all properly. Here’s the compose file:


So when I deploy:

Creating validic-transfer ... done
Attaching to validic-transfer
validic-transfer    | module.js:540
validic-transfer    |     throw err;
validic-transfer    |     ^
validic-transfer    |
validic-transfer    | Error: Cannot find module '/opt/app/server.js'
validic-transfer    |     at Function.Module._resolveFilename (module.js:538:15)
validic-transfer    |     at Function.Module._load (module.js:468:25)
validic-transfer    |     at Function.Module.runMain (module.js:684:10)
validic-transfer    |     at startup (bootstrap_node.js:187:16)
validic-transfer    |     at bootstrap_node.js:608:3
validic-transfer exited with code 1

And when I look:

$ docker-compose -f compose-de-dev.yml run validic-transfer sh
/opt/app # ls -la
total 28
drwxr-xr-x    3 root     root          4096 Feb 26 04:47 .
drwxr-xr-x    1 root     root          4096 Feb 26 14:24 ..
drwxr-xr-x  573 node     root         20480 Feb 26 15:32 node_modules

But when I look this way:

$ docker run -it -entrypoint irewardhealth/validic-transfer sh
/opt/app $ ls
Dockerfile              compose-de-dev.yml      compose-us-qa.yml       logs
LICENSE                 compose-de-live.yml     compose-us-staging.yml  node_modules
Makefile                compose-de-qa.yml       config                  package-lock.json
Procfile                compose-de-staging.yml  docker-compose.yml      package.json               compose-us-dev.yml      docker-de-dev.env       server.js
appConfig.js            compose-us-live.yml     lib                     test

So what am I misunderstanding about docker-compose?

Thanks in advance. :slight_smile:

Ah … the developer before me left this in the compose configuration file:

  - ./:/opt/app

That was what the difference was. This might help in local testing, but it doesn’t help upon actual deploy … problem solved.

1 Like