Docker Community Forums

Share and learn in the Docker community.

Help running composer as non root user in a Docker container

docker

(Reynierpm) #1

I am working on a container that aims to be used by me at work but since I am still learning Docker I need some help from advanced users. So far this is the Dockerfile for the container. That works but now I want to go beyond and:

  • Create a permanent user inside the container used for run composer command and install some PHP Dev libraries as Mess Detector, PHPUnit and some others.
  • I want to use such user (if is not insane) to connect through phpStorm since I am able to setup Docker to be handled from within phpStorm but I need a user in order to properly setup those libraries like for example PHP Code Sniffer

Can any help me to achieve this? The help would be create the user with a proper /home/<username> directory and then run composer as such user so libraries gets installed globally by that user.

Note: composer needs to be installed as root, but should be run as non root user (See https://getcomposer.org/root for detais)