bash - Cannot exit from Docker container -
i've got container run as
docker run -it --rm --name <container_name> <image>:<tag> normally, fall container terminal can exit exit command. now, have dockerfile ends entrypoint runs simple bash script:
#!/usr/bin/env bash # add new user groupadd -r $group --gid $groupid useradd -r $user --uid $userid --gid $groupid # launch application new user su - -c "python <path_to_script>/myscript.py" $user now, once script ends, expected exit container in entrypoint bash script ran again , again (say 10 times).
why container have behavior ?
su manpage says:
-, -l, --login
provide environment similar user expect had user logged in directly
it spawns shell exit comeback parent container shell.
so changing
su - -c "python <path_to_script>/myscript.py" $user to
su "$user" -c "python <path_to_script>/myscript.py" might solution
sidenote : - -c doesn't make sense when objective execute commands , finish job
Comments
Post a Comment