yii-starter-kit / yii2-starter-kit

Yii2 Starter Kit
http://yii2-starter-kit.terentev.net
Other
1.42k stars 648 forks source link

Prevent Docker from running commands as root user #696

Closed XzAeRo closed 3 years ago

XzAeRo commented 5 years ago

Docker runs all commands as root user. This is a huge security issue, and should be avoided.

To fix it, we can modify the Dockerfiles to a format like this:

# run here all commands related to system wide installations, such as pecl packages.

# setup non-root user
RUN useradd --create-home appuser
WORKDIR /home/appuser
USER appuser

# run the rest of the commands as usual but without root access