DevNet Associate DEVASC 200-901 Official Certification Guide by Adrian Iliesiu (z-lib.org)

(andrew) #1
ENV: Sets environment variables within the container.
EXPOSE: Associates a specific port for networking binding.
USER: Sets the UID (or username) of the user that is to run the
container.
VOLUME: Sets up a sharable directory that can be mapped to a local
host directory.
LABEL: Provides a label to identify the created Docker image.

Creating a Dockerfile starts with creating a text file. The
file must be named Dockerfile, and you place it in the
working directory where you want to create an image.
Once you have opened your favorite editor, the syntax is
straightforward. Docker reads the file and operates on it
line by line, so the order in which you build your
Dockerfile should follow the steps you would perform
manually to load your software and configure it. First,
you need to select your foundation. This can be any
container, but in this instance, you can use Ubuntu as the
foundation. If you don’t select a specific version, Docker
defaults to the latest version. You should also provide
details on who created the image with a full name and
email address. Here is an example:


Click here to view code image


FROM ubuntu:16.04
MAINTAINER Cisco Champion ([email protected])

Next, you need to specify the software you want to load
and what components should be added. Just as when
loading software on a Linux server, you first need to run
apt-get update. For this container, you install nginx
and any dependencies:


Click here to view code image


RUN apt-get update && apt-get upgrade -y
RUN apt-get install nginx -y
Free download pdf