docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
33.59k stars 5.18k forks source link

"docker-compose up --no-build" seems to be executing Dockerfile build steps #5644

Closed mnieber closed 6 years ago

mnieber commented 6 years ago

docker-compose version 1.19.0dev

When I run docker-compose --verbose -p test up --no-build I'm getting this in my output:

compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {'AppArmorProfile': '',
 'Args': ['install', '--modules-folder=/srv/jobpal/node_modules'],
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': ['yarn',
                    'install',
                    '--modules-folder=/srv/node_modules'],
            'Domainname': '',
            'Entrypoint': None,

This seems to refer to the following step in my Dockerfile:

RUN yarn install --modules-folder /srv/node_modules

Since I'm using the --no-build option, I expected docker-compose to ignore this build step and only execute the CMD line:

# Run api service
CMD ["node", "index.js"]

Is this a bug?

shin- commented 6 years ago

You're misinterpreting this. Note how the verbose line you quote starts with docker inspect_container; this is exactly what Compose is doing here, retrieving information about containers to inform its behavior. The retrieved information happens to contain said container's command. Without context it's hard to say what caused this specific container to be inspected, but long story short, it isn't a "build step" and it's not a bug.

HTH

mnieber commented 6 years ago

@shin- Sorry, I left out one other important bit of information, which is: the compose up command stopped because yarn install could not reach the node package repository. The reason is that my firewall is blocking it, but the important thing is: it should not try to execute this line.

If you are interested, I could try to create a minimal example that reproduces this behaviour, so it can be inspected more easily.

shin- commented 6 years ago

Can you share the full verbose logs for the up command you're running?

mnieber commented 6 years ago

I simplified my example a bit, and am posting the docker-compose.yml and verbose log output below (I had to anonymize a few names in the docker-compose.yml and output, but otherwise it's the verbatim output):

version: "2"

services:
  foobar-api:
    environment:
      FOOBAR_CONFIG: development
    volumes:
      - ${HOME}/projects/foobar/src:/srv/foobar/src
    image: foobar:foobar-api
maarten@maarten-ThinkPad-T440p ~/projects/foobar/dodo_commands/res $ PYTHONPATH=/home/maarten/sources/compose ~/sources/compose/bin/docker-compose --verbose -p test up --no-build
compose.config.config.find: Using configuration files: ./docker-compose.yml
docker.utils.config.find_config_file: Trying paths: ['/home/maarten/.docker/config.json', '/home/maarten/.dockercfg']
docker.utils.config.find_config_file: Found file at path: /home/maarten/.docker/config.json
docker.auth.load_config: Found 'auths' section
docker.auth.parse_auth: Found entry (registry='https://105577339996.dkr.ecr.eu-west-1.amazonaws.com', username='AWS')
docker.auth.parse_auth: Found entry (registry='https://index.docker.io/v1/', username='mnieber')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.22/version HTTP/1.1" 200 221
compose.cli.command.get_client: docker-compose version 1.19.0dev, build unknown
docker-py version: 3.0.0
CPython version: 3.5.2
OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
compose.cli.command.get_client: Docker base_url: http+docker://localunixsocket
compose.cli.command.get_client: Docker version: MinAPIVersion=1.12, BuildTime=2017-11-02T20:40:23.484070968+00:00, GitCommit=092cba3, KernelVersion=4.4.0-97-generic, GoVersion=go1.6.2, Arch=amd64, Version=1.13.1, Os=linux, ApiVersion=1.26
compose.cli.verbose_proxy.proxy_callable: docker info <- ()
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.22/info HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker info -> {'Architecture': 'x86_64',
 'BridgeNfIp6tables': True,
 'BridgeNfIptables': True,
 'CPUSet': True,
 'CPUShares': True,
 'CgroupDriver': 'cgroupfs',
 'ClusterAdvertise': '',
 'ClusterStore': '',
 'ContainerdCommit': {'Expected': 'aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1',
                      'ID': ''},
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_network <- ('test_default')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.22/networks/test_default HTTP/1.1" 200 378
compose.cli.verbose_proxy.proxy_callable: docker inspect_network -> {'Attachable': False,
 'Containers': {},
 'Created': '2018-02-04T19:27:43.268549408+01:00',
 'Driver': 'bridge',
 'EnableIPv6': False,
 'IPAM': {'Config': [{'Gateway': '172.19.0.1', 'Subnet': '172.19.0.0/16'}],
          'Driver': 'default',
          'Options': None},
 'Id': 'dc77bf13bda75d0b70008b0f2e78c68b73afd5a0aaf9eda78ef9c5eeb18863f9',
 'Internal': False,
...
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=False, filters={'label': ['com.docker.compose.project=test', 'com.docker.compose.oneoff=False']})
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.22/containers/json?limit=-1&size=0&filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dtest%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D&all=0&trunc_cmd=0 HTTP/1.1" 200 3
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 0 items)
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=True, filters={'label': ['com.docker.compose.project=test', 'com.docker.compose.service=foobar-api', 'com.docker.compose.oneoff=False']})
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.22/containers/json?limit=-1&size=0&filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dtest%22%2C+%22com.docker.compose.service%3Dfoobar-api%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D&all=1&trunc_cmd=0 HTTP/1.1" 200 1173
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 1 items)
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- ('f6d5a4e66a3a9258a14caff7f7d091522bba92fd495bfa315657910259f8ce4a')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.22/containers/f6d5a4e66a3a9258a14caff7f7d091522bba92fd495bfa315657910259f8ce4a/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {'AppArmorProfile': '',
 'Args': ['install', '--modules-folder=/srv/foobar/node_modules'],
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': ['yarn',
                    'install',
                    '--modules-folder=/srv/foobar/node_modules'],
            'Domainname': '',
            'Entrypoint': None,
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- ('foobar:foobar-api')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.22/images/foobar:foobar-api/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> {'Architecture': 'amd64',
 'Author': '',
 'Comment': '',
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': ['yarn',
                    'install',
                    '--modules-folder=/srv/foobar/node_modules'],
            'Domainname': '',
...
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=True, filters={'label': ['com.docker.compose.project=test', 'com.docker.compose.service=foobar-api', 'com.docker.compose.oneoff=False']})
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.22/containers/json?limit=-1&size=0&filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dtest%22%2C+%22com.docker.compose.service%3Dfoobar-api%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D&all=1&trunc_cmd=0 HTTP/1.1" 200 1173
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 1 items)
compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- ('foobar:foobar-api')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.22/images/foobar:foobar-api/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> {'Architecture': 'amd64',
 'Author': '',
 'Comment': '',
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': ['yarn',
                    'install',
                    '--modules-folder=/srv/foobar/node_modules'],
            'Domainname': '',
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- ('f6d5a4e66a3a9258a14caff7f7d091522bba92fd495bfa315657910259f8ce4a')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.22/containers/f6d5a4e66a3a9258a14caff7f7d091522bba92fd495bfa315657910259f8ce4a/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {'AppArmorProfile': '',
 'Args': ['install', '--modules-folder=/srv/foobar/node_modules'],
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': ['yarn',
                    'install',
                    '--modules-folder=/srv/foobar/node_modules'],
            'Domainname': '',
            'Entrypoint': None,
...
compose.service._containers_have_diverged: test_foobar-api_1 has diverged: 762af10f798890fa5aad5ce8ca9f5684536e209ff271dbf06d59d6ab7730371b != eb61ef1ec250875ba70fb14eb2872ef997eb11f9d5a269d89a25afe047487b2f
compose.parallel.feed_queue: Pending: {<Service: foobar-api>}
compose.parallel.feed_queue: Starting producer thread for <Service: foobar-api>
Recreating test_foobar-api_1 ... 
compose.parallel.feed_queue: Pending: {<Container: test_foobar-api_1 (f6d5a4)>}
compose.parallel.feed_queue: Starting producer thread for <Container: test_foobar-api_1 (f6d5a4)>
compose.cli.verbose_proxy.proxy_callable: docker stop <- ('f6d5a4e66a3a9258a14caff7f7d091522bba92fd495bfa315657910259f8ce4a', timeout=10)
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.22/containers/f6d5a4e66a3a9258a14caff7f7d091522bba92fd495bfa315657910259f8ce4a/stop?t=10 HTTP/1.1" 304 0
compose.cli.verbose_proxy.proxy_callable: docker stop -> None
compose.cli.verbose_proxy.proxy_callable: docker rename <- ('f6d5a4e66a3a9258a14caff7f7d091522bba92fd495bfa315657910259f8ce4a', 'f6d5a4e66a3a_test_foobar-api_1')
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.22/containers/f6d5a4e66a3a9258a14caff7f7d091522bba92fd495bfa315657910259f8ce4a/rename?name=f6d5a4e66a3a_test_foobar-api_1 HTTP/1.1" 204 0
compose.cli.verbose_proxy.proxy_callable: docker rename -> None
compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- ('foobar:foobar-api')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.22/images/foobar:foobar-api/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> {'Architecture': 'amd64',
 'Author': '',
 'Comment': '',
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': ['yarn',
                    'install',
                    '--modules-folder=/srv/foobar/node_modules'],
            'Domainname': '',
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- ('sha256:a70f372fb9ae8da51f551af218b0810cf03762a0b96189978ed40e969cb085f0')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.22/images/sha256:a70f372fb9ae8da51f551af218b0810cf03762a0b96189978ed40e969cb085f0/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> {'Architecture': 'amd64',
 'Author': '',
 'Comment': '',
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': ['yarn',
                    'install',
                    '--modules-folder=/srv/foobar/node_modules'],
            'Domainname': '',
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- ('foobar:foobar-api')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.22/images/foobar:foobar-api/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> {'Architecture': 'amd64',
 'Author': '',
 'Comment': '',
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': ['yarn',
                    'install',
                    '--modules-folder=/srv/foobar/node_modules'],
            'Domainname': '',
...
compose.service.build_container_labels: Added config hash: f0f1f65b5a80220b6ebb979cfcc9b7e7da2882801adc18e44488cbedb7b7d94a
compose.cli.verbose_proxy.proxy_callable: docker create_host_config <- (device_read_bps=None, cpu_quota=None, ulimits=None, oom_score_adj=None, init=None, device_write_iops=None, oom_kill_disable=None, device_write_bps=None, device_read_iops=None, storage_opt=None, volume_driver=None, memswap_limit=None, devices=None, cgroup_parent=None, extra_hosts=None, cpuset_cpus=None, init_path=None, nano_cpus=None, blkio_weight_device=None, shm_size=None, isolation=None, privileged=False, pid_mode=None, group_add=None, cpu_shares=None, cap_drop=None, mem_limit=None, mem_swappiness=None, cpu_percent=None, dns_search=None, network_mode='test_default', mem_reservation=None, binds=['/home/maarten/projects/foobar/src:/srv/foobar/src:rw'], mounts=None, port_bindings={}, dns=None, cpu_count=None, blkio_weight=None, tmpfs=[], pids_limit=None, ipc_mode=None, links=[], log_config={'Config': {}, 'Type': ''}, sysctls=None, restart_policy=None, dns_opt=None, read_only=None, runtime=None, security_opt=None, volumes_from=[], cap_add=None, userns_mode=None)
compose.cli.verbose_proxy.proxy_callable: docker create_host_config -> {'Binds': ['/home/maarten/projects/foobar/src:/srv/foobar/src:rw'],
 'Links': [],
 'LogConfig': {'Config': {}, 'Type': ''},
 'NetworkMode': 'test_default',
 'PortBindings': {},
 'VolumesFrom': []}
compose.cli.verbose_proxy.proxy_callable: docker create_container <- (labels={'com.docker.compose.config-hash': 'f0f1f65b5a80220b6ebb979cfcc9b7e7da2882801adc18e44488cbedb7b7d94a', 'com.docker.compose.oneoff': 'False', 'com.docker.compose.container-number': '1', 'com.docker.compose.service': 'foobar-api', 'com.docker.compose.version': '1.19.0dev', 'com.docker.compose.project': 'test'}, volumes={'/srv/foobar/src': {}}, image='foobar:foobar-api', networking_config={'EndpointsConfig': {'test_default': {'Aliases': ['foobar-api'], 'IPAMConfig': {}}}}, host_config={'VolumesFrom': [], 'NetworkMode': 'test_default', 'Links': [], 'LogConfig': {'Config': {}, 'Type': ''}, 'PortBindings': {}, 'Binds': ['/home/maarten/projects/foobar/src:/srv/foobar/src:rw']}, name='test_foobar-api_1', detach=True, environment=['FOOBAR_CONFIG=development'])
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.22/containers/create?name=test_foobar-api_1 HTTP/1.1" 201 90
compose.cli.verbose_proxy.proxy_callable: docker create_container -> {'Id': '563c04b81c0334096c5507fe1ec8e41444d7b0b14614a53d1ed4d37da53e6f55',
 'Warnings': None}
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- ('563c04b81c0334096c5507fe1ec8e41444d7b0b14614a53d1ed4d37da53e6f55')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.22/containers/563c04b81c0334096c5507fe1ec8e41444d7b0b14614a53d1ed4d37da53e6f55/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {'AppArmorProfile': '',
 'Args': ['install', '--modules-folder=/srv/foobar/node_modules'],
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': ['yarn',
                    'install',
                    '--modules-folder=/srv/foobar/node_modules'],
            'Domainname': '',
            'Entrypoint': None,
...
compose.cli.verbose_proxy.proxy_callable: docker attach <- ('563c04b81c0334096c5507fe1ec8e41444d7b0b14614a53d1ed4d37da53e6f55', stdout=True, stream=True, stderr=True)
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.22/containers/563c04b81c0334096c5507fe1ec8e41444d7b0b14614a53d1ed4d37da53e6f55/attach?stream=1&stdout=1&logs=0&stderr=1 HTTP/1.1" 101 0
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.22/containers/563c04b81c0334096c5507fe1ec8e41444d7b0b14614a53d1ed4d37da53e6f55/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker attach -> <generator object frames_iter at 0x7f181ca53fc0>
compose.cli.verbose_proxy.proxy_callable: docker disconnect_container_from_network <- ('563c04b81c0334096c5507fe1ec8e41444d7b0b14614a53d1ed4d37da53e6f55', 'test_default')
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.22/networks/test_default/disconnect HTTP/1.1" 200 0
compose.cli.verbose_proxy.proxy_callable: docker disconnect_container_from_network -> None
compose.service.connect_container_to_networks: Connecting to test_default
compose.cli.verbose_proxy.proxy_callable: docker connect_container_to_network <- ('563c04b81c0334096c5507fe1ec8e41444d7b0b14614a53d1ed4d37da53e6f55', 'test_default', aliases=['foobar-api', '563c04b81c03'], links=[], link_local_ips=None, ipv4_address=None, ipv6_address=None)
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.22/networks/test_default/connect HTTP/1.1" 200 0
compose.cli.verbose_proxy.proxy_callable: docker connect_container_to_network -> None
compose.cli.verbose_proxy.proxy_callable: docker start <- ('563c04b81c0334096c5507fe1ec8e41444d7b0b14614a53d1ed4d37da53e6f55')
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.22/containers/563c04b81c0334096c5507fe1ec8e41444d7b0b14614a53d1ed4d37da53e6f55/start HTTP/1.1" 204 0
compose.cli.verbose_proxy.proxy_callable: docker start -> None
compose.cli.verbose_proxy.proxy_callable: docker remove_container <- ('f6d5a4e66a3a9258a14caff7f7d091522bba92fd495bfa315657910259f8ce4a')
urllib3.connectionpool._make_request: http://localhost:None "DELETE /v1.22/containers/f6d5a4e66a3a9258a14caff7f7d091522bba92fd495bfa315657910259f8ce4a?link=False&v=False&force=False HTTP/1.1" 204 0
compose.cli.verbose_proxy.proxy_callable: docker remove_container -> None
Recreating test_foobar-api_1 ... done
compose.parallel.feed_queue: Pending: set()
compose.parallel.parallel_execute_iter: Finished processing: <Service: foobar-api>
compose.parallel.feed_queue: Pending: set()
Attaching to test_foobar-api_1
compose.cli.verbose_proxy.proxy_callable: docker events <- (decode=True, filters={'label': ['com.docker.compose.project=test', 'com.docker.compose.oneoff=False']})
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.22/events?filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dtest%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker events -> <generator object APIClient._stream_helper at 0x7f181ca53bf8>
foobar-api_1  | yarn install v0.24.6
foobar-api_1  | [1/4] Resolving packages...
foobar-api_1  | error An unexpected error occurred: "https://registry.yarnpkg.com/elasticsearch: getaddrinfo EAI_AGAIN registry.yarnpkg.com:443".
foobar-api_1  | info If you think this is a bug, please open a bug report with the information provided in "/srv/foobar/src/foobar-api/yarn-error.log".
foobar-api_1  | info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
compose.cli.verbose_proxy.proxy_callable: docker wait <- ('563c04b81c0334096c5507fe1ec8e41444d7b0b14614a53d1ed4d37da53e6f55')
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- ('563c04b81c0334096c5507fe1ec8e41444d7b0b14614a53d1ed4d37da53e6f55')
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.22/containers/563c04b81c0334096c5507fe1ec8e41444d7b0b14614a53d1ed4d37da53e6f55/wait HTTP/1.1" 200 17
compose.cli.verbose_proxy.proxy_callable: docker wait -> {'StatusCode': 1}
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.22/containers/563c04b81c0334096c5507fe1ec8e41444d7b0b14614a53d1ed4d37da53e6f55/json HTTP/1.1" 200 None
test_foobar-api_1 exited with code 1
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {'AppArmorProfile': '',
 'Args': ['install', '--modules-folder=/srv/foobar/node_modules'],
 'Config': {'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': ['yarn',
                    'install',
                    '--modules-folder=/srv/foobar/node_modules'],
            'Domainname': '',
            'Entrypoint': None,
shin- commented 6 years ago

Okay - I see that the yarn install ... command is happening, but this is at runtime, not build time. It seems you're not specifying a command for the foobar-api service, which means it will use the default command associated with the foobar:foobar-api image - and that default command for some reason seems to be yarn install --modules-folder=/serv/foobar/node_modules (either because your Dockerfile specifies it as a CMD entry, or because the image you're inheriting via FROM set that as its CMD and wasn't overridden).

What you want to do is override the default command with the one you actually want to run, either by updating your Dockerfile or specifying the appropriate command in your Compose file.

mnieber commented 6 years ago

Sorry, I wanted to post the Dockerfile as well, but forgot to press Comment. Here it is (the CMD just starts node, it does not install packages):

FROM foobar/base:latest

ADD . /srv/foobar/src/foobar-api
WORKDIR /srv/foobar/src/foobar-api

# install api package
ENV NODE_PATH /srv/foobar/node_modules/
RUN yarn install --modules-folder /srv/foobar/node_modules

# Expose api port
EXPOSE 8003

# Run api service
CMD ["node", "index.js"]
shin- commented 6 years ago

@mnieber Looks like you need to re-build / re-tag your image to use the result of this Dockerfile, because that's not the image that's being used by Compose right now - it's most likely outdated. You can check for yourself if you run docker inspect foobar:foobar-api and look at the Config.Cmd field.

mnieber commented 6 years ago

@shin- Thanks, that solved it! I was bitten by something unexpected, I will explain. The yarn install call was never a CMD instruction in my Dockerfile, but it was used in a call to docker run, followed by a call to docker commit that saves the docker container as a docker image (in this case: foobar:foobar-api). I use this as a trick to update the packages in my foobar:foobar-api image without having to reinstall all packages from scratch. I was not aware however that this alters the Cmd value that is stored inside the foobar:foobar-api image (to be honest, I still find this surprising).

I think that for my use-case, I can just set the command option to node index.js in my docker-compose.yml. Thanks very much for your help!

shin- commented 6 years ago

Glad I could help! :+1: