A
A
Alexander2018-10-03 16:29:41
Docker
Alexander, 2018-10-03 16:29:41

What is the difference between deploy description in docker-compose command and ENTRYPOINT?

docker-compose.yml:

...
    web:
        restart: always
        build: .
        image: web
        command: bash -c "
                 python manage.py collectstatic --no-input &&
                 python manage.py migrate &&
                 gunicorn config.wsgi -b 0.0.0.0"
        volumes:
            - ~/myjob_files/static:/static
            - ~/myjob_files/uploads:/uploads
            - ~/myjob_files/nginx:/nginx
        expose:
            - "8000"
        links:
            - db
...

.gitlab-ci.yml:
deploy:
    stage: deploy
    script:
        - docker-compose down
        - docker-compose up -d
    only:
        - master

But I also noticed that some people set ENTRYPOINT ["/docker-entrypoint.sh"] and already in this file describe the deployment. I can't figure out what's the difference? so for me my version is more concise.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Q
qq1, 2018-10-03
@qq1

ENTRYPOINTdefines a command that will be executed when the container is started.
CMDdefines the arguments to be passed to ENTRYPOINT.
Docker defaults ENTRYPOINTto /bin/sh -c
In turn, commandthe parameter in docker-compose.ymloverrides CMDfrom the dockerfile.
That's all the differences.
Regarding conciseness, what is related to the container itself and what does not depend on the environment in which the container is launched is more logical to remove in Dockerfile/entrypoint.sh in order to avoid duplication in case of several docker-compose.yml

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question