0% found this document useful (0 votes)
61 views

Sudo Yum Update - Y: Docker Lab

This document provides instructions for setting up Docker on an Amazon Linux instance and creating a simple Docker image for a web application. It outlines steps to: 1) Install and configure Docker, 2) Create a Dockerfile to define the image using Ubuntu 16.04 as the base and installing packages for a web server, 3) Build the image from the Dockerfile, 4) Run the image with port 80 exposed, and 5) View the "Hello World!" page in a browser.

Uploaded by

Vipul Zope
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Sudo Yum Update - Y: Docker Lab

This document provides instructions for setting up Docker on an Amazon Linux instance and creating a simple Docker image for a web application. It outlines steps to: 1) Install and configure Docker, 2) Create a Dockerfile to define the image using Ubuntu 16.04 as the base and installing packages for a web server, 3) Build the image from the Dockerfile, 4) Run the image with port 80 exposed, and 5) View the "Hello World!" page in a browser.

Uploaded by

Vipul Zope
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Docker Lab

1. Update the installed packages and packages cache on your instance.

sudo yum update -y

2. Install the most recent Docker Community Edition package.

sudo amazon-linux-extras install docker

3. Start the Docker service.

sudo service docker start

4. Add the ec2-user to the docker group so you can execute Docker commands
without using sudo.

sudo usermod -a -G docker ec2-user

5. Verify that the user can run Docker commands

sudo docker info

To create a Docker image of a simple web application

1. Create a file called Dockerfile. A Dockerfile is a manifest that describes the


base image to use for your Docker image and what you want installed and
running on it. For more information about Dockerfiles, go to the Dockerfile
Reference.

touch Dockerfile

2. Edit the Dockerfile you just created using vi/any other editor and add the
following content.
This Dockerfile uses the Ubuntu 16.04 image. The RUN instructions update the
package caches, install some software packages for the web server, and then
write the "Hello World!" content to the web server's document root.
The EXPOSE instruction exposes port 80 on the container, and
the CMD instruction starts the web server.

3. Build the Docker image from your Dockerfile.

Note - Some versions of Docker may require the full path to your
Dockerfile in the following command, instead of the relative path
shown below.
docker build -t hello-world .

4. Run docker images to verify that the image was created correctly.

docker images --filter reference=hello-world

Output:

REPOSITORY TAG IMAGE ID CREATED


SIZE
hello-world latest e9ffedc8c286 4 minutes
ago 241MB

5. Run the newly built image. The -p 80:80 option maps the exposed port 80 on
the container to port 80 on the host system. For more information
about docker run, go to the Docker run reference.

docker run -t -i -p 80:80 hello-world

6. Open a browser and point to the server that is running Docker and hosting
your container.
Note : If you are using an EC2 instance, this is the Public DNS value for the
server, which is the same address you use to connect to the instance with SSH.
Make sure that the security group for your instance allows inbound traffic on port 80.

7. Stop the Docker container by typing Ctrl + c.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy