Docker Community Forums

Share and learn in the Docker community.

Switching users during "CMD"

docker

(Tinysponsor) #1

Hi everyone,

I’m fairly new to docker so my question may sound stupid. I am trying to deploy a django application using docker. There are commands like migrate or collectstatic that needed to be executed by my app user (it’s a new user I create on my Dockerfile). So I have a file called container_start.sh that I call using CMD. Now when all the commands are executed, I need to call supervisord -n as root. The issue is using sudo should be avoided according to https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/. So how can I actually switch between my web user and root during CMD?

Thanks