Have you failed a job interview?
Send us your job interview questions and get correct answers.

What is the USER instruction good for in Docker?

Experience Level: Senior
Tags: Docker

Answer

The USER instruction sets the user name (or UID) and optionally the user group (or GID) to use when running the image and for any RUN, CMD and ENTRYPOINT instructions that follow it in the Dockerfile.

Note that when specifying a group for the user, the user will have only the specified group membership. Any other configured group memberships will be ignored.

Example:
FROM ubuntu:latest
RUN apt-get -y update
RUN groupadd -r user && useradd -r -g user user
USER user

Comments

No Comments Yet.
Be the first to tell us what you think.
Docker instructions
Docker instructions

Are you learning Docker ? Try our test we designed to help you progress faster.

Test yourself