Reputation: 337
Im trying to write a docker image for s3cmd. When I run the image built from the Dockerfile via docker-compose, the container exit before the command in docker compose run.
Dockerfile
FROM alpine:latest
COPY ./.s3cfg /s3cmd_repo/.s3cfg.example
COPY entrypoint.sh /s3cmd_repo/
RUN chmod +x /s3cmd_repo/entrypoint.sh
ENTRYPOINT ["/s3cmd_repo/entrypoint.sh"]
entrypoint.sh
#!/bin/sh
echo "--- INITIALIZING SS# CONFIGURATIONS ---"
envsubst < /s3cmd_repo/.s3cfg.example > ~/.s3cfg
s3cmd ls
echo "=== END ==="
docker-compose.yml
version: '3'
services:
execution:
image: s3
command: s3cmd ls
I also tried using tail -f /etc/issue
, the container did not exit, but the docker compose command could not run.
Upvotes: 3
Views: 2946
Reputation: 131336
When I run the image built from the Dockerfile via docker-compose, the container exit before the command in docker compose run.
That is expected. That command in the docker compose file : s3cmd ls
is appended to the entrypoint of your s3' Dockerfile.
So something like that is executed :
/s3cmd_repo/entrypoint.sh s3cmd ls
the two args are just ignored during the sh script execution.
To execute multiple commands to start a container, you don't need to define an ENTRYPOINT. Instead specify the commands to run in the docker-compose file :
version: '3'
services:
execution:
image: s3
command: sh -c "/s3cmd_repo/entrypoint.sh && s3cmd ls"
Note that sh
works in any Linux distrib, bash
doesn't (Alpine for example).
Upvotes: 3