Problem description
I need to create some directories and manage some files when a container is instantiated, and not when the image is built. Consequently, I’ve put the commands to perform these tasks in the docker-compose.yaml and not in the Dockerfile.
The problem that I’m encountering is that I can’t get any command to run properly from within the docker-compose.yaml. I get weird errors like.
Unrecognized alias: 'c', it will have no effect
when I run a command with /bin/bash -c
or
No such file or directory: /app/bash
when I run a command with bash
, i.e. without /bin
similarly, if I try to run a python script I get
No such file or directory: /app/python
here is my docker-compose.yaml:
version: "3.4"
services:
app:
build:
context: ./
target: project_build
image: sig-project
environment:
PROJECT_NAME: "${PROJECT_NAME:-NullProject}"
command: /bin/bash -c "init_project.sh"
ports:
- 7777:7777
expose:
- 7777
volumes:
- ./$PROJECT_NAME:/app/$PROJECT_NAME
- .:/home/jovyan/work
working_dir: /app
entrypoint: "jupyter notebook --ip=0.0.0.0 --port=7777 --allow-root --no-browser"
Problem location
I’m not sure what the source of the problem is. It’s clear from the error messages that the shell is looking for command folders in the working dir, but I’m not sure why this is or how to change it.
Project version(s) affected
Docker desktop version: 4.11.0 (83626)
Engine version: 20.10.17
$ docker-compose version
docker-compose version 1.29.2, build 5becea4c
docker-py version: 5.0.0
CPython version: 3.9.0
OpenSSL version: OpenSSL 1.1.1h 22 Sep 2020