Coder Social home page Coder Social logo

containersonazure_simpledocker_arcadia's Introduction

A simple intro to Docker




Step 1 - Install Docker:

This has been completed in advance. Access your 'Docker' VM using Guacamole.


Images key:

Line Colour What is it showing?
Purple The path of your access to various machines
Black Console commands and locations
Dark Blue Docker control plane
Green Docker actions/events
Red Standard 'Data Plane' comms
Yellow Network (logical)

Docker-specific key:

Character Item
"i:" Image
"c:" Container (from image)
"l:" Writeable union filesystem layer atop image

Step 1 Image



Step 2 - Run a container using the 'Hello World' image:

sudo docker run hello-world

Note the "Unable to find image 'hello-world:latest' locally" and the subsequent "Pulling" message.


Step 2 Image



Step 3 - Pull down an image from Docker Hub before running a container:

sudo docker pull ubuntu:latest

Step 3 Image



Step 4 - Run a container based on the image pulled down in Step 3 and attach:

sudo docker run -it ubuntu:latest /bin/bash

Step 4 Image



Step 5 - Exit the container and clear up:

exit

or


'Ctrl+d'



sudo docker ps -a
sudo docker rm <idofcontainercopiedfromlastoutput>



Step 6 - Run another container based on the image pulled down in Step 3, attach to it, install Nginx, test the service, and exit:

On your 'Docker VM':

ifconfig -a

Note down the IP address on 'Eth0'.



sudo docker run -it -p 80:80 --net=host ubuntu /bin/bash

Step 6 Image a


On the container:

apt-get update
apt-get install nano -y
apt-get install nginx -y
nano /var/www/html/index.nginx-debian.html

Edit the html file in any way you see fit


'Ctrl+o', 'Ctrl+x' to save and exit nano


Start nginx:

/etc/init.d/nginx start

Step 6 Image b


On your 'Mgmt VM' (Windows), browse to:

http://<dockervmipadress>

You should see an Nginx welcome page with your edits.


Step 6 Image c



Step 7 - Build a new image based on the addition of a new layer that was added in Step 6 atop the original 'Ubuntu' image:

Back on the 'Docker VM':

sudo docker ps -a

Create a new image based on the ubuntu image + the changes made:

sudo docker commit <idofcontainerlistedinthelastoutput> <yourfirstname>/nginx

Step 7 Image a


Remove the container that we used to build a new image:

sudo docker rm <idofcontainerlistedinthelastoutput>

Run a new container based on the image created above and start the nginx service in the background:

sudo docker run -d -p 80:80 --net=host <yourfirstname>/nginx nginx -g 'daemon off;'

See the '-d' switch which runs the container in the background (i.e. you'll remain at the prompt provided by your 'Docker VM' after seeing an ID printed to screen which is the new container's ID).


Step 7 Image b



On 'Mgmt VM', browse to:

http://<dockervmipadress>

You should see the page that you edited again.

Note. The new image is currently only stored locally as it's not been pushed to a registry such as Docker Hub or Azure Container Registry. This would mean a lack of 'portability'.


Step 7 Image c



Clear up:

sudo docker ps
sudo docker stop <idofcontainerlistedinthelastoutput>
sudo docker rm <idofcontainerlistedinthelastoutput>



Step 8 - Inspect the layers of our image:

sudo docker history <yourfirstname>/nginx

See the /bin/bash layer at the top that's added ~96.5MB.



Step 9 - Declaratively template the process that we've just run through using a 'Dockerfile':

On your 'Docker VM':

sudo mkdir nginxdockerfile
cd nginxdockerfile
sudo nano Dockerfile

Type in:


FROM ubuntu 

RUN apt-get update

RUN apt-get install -y nginx

RUN echo "\ndaemon off;" >> /etc/nginx/nginx.conf

CMD ["nginx"]

EXPOSE 80

'Ctrl+o', 'Ctrl+x' to save and exit.



Perform a build using the Dockerfile just created:

sudo docker build -t <yourfirstname>/nginx2 .



Run a container using the new image:

sudo docker run -d -p 80:80 --net=host <yourfirstname>/nginx2

Test on 'Mgmt VM' by browsing to:

http://<dockervmipadress>



Step 10 - Declaratively template a multi-container template using Docker Compose

Richard to demonstrate.

containersonazure_simpledocker_arcadia's People

Contributors

rbannist avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

lulzzz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.