Sudo Yum Update - Y: Docker Lab
Sudo Yum Update - Y: Docker Lab
4. Add the ec2-user to the docker group so you can execute Docker commands
without using sudo.
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.
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.
Output:
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.
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.