Install Nano on container startup?

Viewed 490

Using docker compose, I have a container that runs fine without my additional code. Now I just want to install nano upon it's startup. So far, with the code I'm using, and looking at the logs before it closes, it's installing nano fine; the issue is that as soon as it installs nano, the container exits (without error).

I'm simply adding the line:

command: ["sh", "-c", "apk add nano"]

My assumption is that as soon as it finishes running the command, it thinks it's supposed to now close for some reason, rather than keep running as is normally does w/out that added command, so I've tried adding the following 2 alternatives, with the same result

command: ["sh", "-c", "apk add nano", "--wait"]

command: ["sh", "-c", "apk add nano", "-d"]

Seems like a simple fix, but I'm coming up empty in my searches.

NOTE: this container doesn't have bash, so I'm using sh.

Update:

compose code is:

    gitea:
        image: gitea/gitea:1
        hostname: gitea
        environment:
            TZ: ${TZ}
        volumes:
            - /opt/docker/configs/Gitea/data:/data:rw
            - /mnt/h/Logs/gitea:/data/gitea/log:rw
            - /etc/localtime:/etc/localtime:ro
        command: ["/bin/sh", "-c", "apk add nano"]
        networks:
            - oc
        deploy:
            mode: replicated
            replicas: 1
            placement:
                constraints:
                - node.labels.MainDaemon == true
            resources:
              limits:
                memory: 500M
            restart_policy:
                condition: any
0 Answers
Related