Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker compose & docker-entrypoint

When running docker-compose up --build I am always running into this error message. Anyone knows what I am doing wrong with the docker-entrypoint file?

ERROR: for 986991ccdfe1_ubercoach_web_1  Cannot start service web: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"./docker-entrypoint.sh\": permission denied": unknown

ERROR: for web  Cannot start service web: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"./docker-entrypoint.sh\": permission denied": unknown
ERROR: Encountered errors while bringing up the project.

docker-compose:

version: '3'

services:
  db:
    image: postgres
    ports:
      - "5432:5432"
  web:
    build: .
    entrypoint: ./docker-entrypoint.sh
    env_file: .env
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    depends_on:
      - db

Dockerfile:

# Pull base image FROM python:3

# Set environment varibles
ENV PYTHONUNBUFFERED 1

# Set work directory
RUN mkdir /code
WORKDIR /code

# Install dependencies
RUN pip install --upgrade pip
RUN pip install pipenv
COPY ./Pipfile /code/Pipfile
RUN pipenv install --deploy --system --skip-lock --dev

# Copy project
COPY . /code/

docker-entrypoint.sh

#!/bin/bash

# Collect static files
echo "Collect static files"
python manage.py collectstatic --noinput

# Apply database migrations
echo "Apply database migrations"
python manage.py migrate

# Start server
echo "Starting server"
python manage.py runserver 0.0.0.0:8000
like image 929
Joey Coder Avatar asked Oct 23 '18 06:10

Joey Coder


People also ask

What is a docker compose?

Docker Compose is a tool that was developed to help define and share multi-container applications. With Compose, we can create a YAML file to define the services and with a single command, can spin everything up or tear it all down.

What is docker compose vs Dockerfile?

Difference between docker-compose and Dockerfile. The key difference between the Dockerfile and docker-compose is that the Dockerfile describes how to build Docker images, while docker-compose is used to run Docker containers.

Is docker compose like Kubernetes?

Kubernetes and Docker Compose are both container orchestration frameworks. Kubernetes runs containers over a number of computers, virtual or real. Docker Compose runs containers on a single host machine.

What does docker compose run do?

The docker compose run command is for running “one-off” or “adhoc” tasks. It requires the service name you want to run and only starts containers for services that the running service depends on. Use run to run tests or perform an administrative task such as removing or adding data to a data volume container.


1 Answers

\"./docker-entrypoint.sh\": permission denied": unknown

I would guess your docker-entrypoint.sh doesn't have execute permissions (x). But also docker-compose.yml is not really the best place for the docker-entrypoint.sh. It's the override setting, see entrypoint. The default should go in the Dockerfile. Try this:

Add this to the end of your Dockerfile

COPY ./docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]

The docker-entrypoint.sh should be in the same folder as the Dockerfile (or adjust the COPY path). Remove the entrypoint line from your docker-compose.yml. Rebuild, rerun.

like image 132
hjsimpson Avatar answered Sep 18 '22 14:09

hjsimpson