简体   繁体   中英

How ENTRYPOINT and CMD works between base and current image?

somedockerhub/backend-base has ENTRYPOINT ["entrypoint.sh"]

where entrypoint.sh is:

#!/bin/bash
. /appenv/bin/activate
exec $@

Below is the docker-compose file:

app:
  build: ../../
  dockerfile: docker/release/Dockerfile
  links:
    - dbc
  volumes_from:
    - webroot
  environment:
    DJANGO_SETTINGS_MODULE: todobackend.settings.release
    MYSQL_HOST: db
    MYSQL_USER: user1
    MYSQL_PASSWORD: passwd
  command:
    - uwsgi
    - "--socket /var/www/someapp/someapp.sock"
    - "--chmod-socket=666"
    - "--module someapp.wsgi"
    - "--master"
    - "--die-on-term"

where docker/release/Dockerfile :

FROM somedockerhub/backend-base:latest


# Copy application artifacts
COPY target /wheelhouse

# Install application
RUN . /appenv/bin/activate && \
    pip install --no-index -f /wheelhouse someapp
    rm -rf /wheelhouse

ENTRYPOINT ["echo"]

1)

For container launched by app service

Does ENTRYPOINT ["entrypoint.sh"] get executed before ENTRYPOINT ["echo"] ?

2)

Assume there is no entry point in current image, does current image execute base image entry point and then command instruction launch uwsgi process with pid 1?

For container launched by app service

Does ENTRYPOINT ["entrypoint.sh"] get executed before ENTRYPOINT ["echo"]?

No, ENTRYPOINT ["echo"] overrides ENTRYPOINT ["entrypoint.sh"] of the base image.

So ENTRYPOINT ["echo"] will run and it will receive:

command: - uwsgi - "--socket /var/www/someapp/someapp.sock" - "--chmod-socket=666" - "--module someapp.wsgi" - "--master" - "--die-on-term"

as argument

Assume there is no entry point in current image, does current image execute base image entry point and then command instruction launch uwsgi process with pid 1?

Yes entrypoint.sh will run. It will receive command value as argument.

entrypoint code exec $@ means: execute all the script ( enterypoint.sh ) arguments (uwsgi...) .

exec by definition doesn't generate new process, rather loads uwsgi into memory of existing process. Because exec process is launched with pid 1, uwsgi will receive pid 1.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM