Junior — Middle
Can you explain what the RUN command in a Dockerfile means and what role it plays in the container build process?
sobes.tech AI
Answer from AI
The RUN command in a Dockerfile is used to execute commands inside the image during its build stage. It allows you to run any shell commands, such as installing packages, configuring the environment, or compiling programs. The result of the command execution is saved in a new image layer, which is then used to create a container.
Example:
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y curl
In this example, the RUN command updates the package list and installs curl inside the image. Thus, RUN plays a key role in shaping the final state of the image by adding necessary dependencies and configurations.