wiki:Csle2022/Agenda/Containers

Version 3 (modified by dushmantha, 19 months ago) ( diff )

--

LXC Lab

In this lab, you will setup a LXC.

Requirements:

Participants are requested to have a computer with Windows 8/10/11 (8GB RAM, 25GB free disk space) with Virtualbox (version 6 or higher) hypervisor and PuTTY installed.

In Virtualbox, 'Extension pack' should be installed.

A wired internet connection is preferred.

Virtual Machine (VM) Setup

Download VM from the following Link.

https://docs.learn.ac.lk/index.php/s/YcojJ2544b40Zw4

Import the VM to Virtualbox.

Username and Password: docker

May have to create Virtualbox Host-Only Network Adapter

File > Host Network Manager > Create

Test internet connectivity.

Login using PuTTY.

Setup LXC

Initiate LXC.

sudo lxd init

Cloning

Docker Lab

In this lab, you will setup Docker and customize Docker images.

Requirements:

Same as the above LXC lab.

VM Setup

Download VM from the following Link.

https://docs.learn.ac.lk/index.php/s/YcojJ2544b40Zw4

Import the VM to Virtualbox.

Username and Password: docker

May have to create Virtualbox Host-Only Network Adapter

File > Host Network Manager > Create

Test internet connectivity.

Login using Putty.

Login as root to the provided VM.

Setup Docker

apt-get install -y docker.io
systemctl enable docker.service

Managing Docker

List Docker images

docker image ls

Docker image search

docker search <image name>

Download a Docker image

docker pull <image name>

List docker containers that are currently running

docker container ls

Run a Docker image

docker run -d --name <name> -p 80:80 -d <image name>

Stop a Docker container

docker stop <container name/ID>

Setup a Docker image

Create a directory and go inside it.

mkdir <directory name>
cd <directory name>

Make Dockerfile and insert the following content to it.

FROM php:8.0-apache
COPY index.php /var/www/html/
EXPOSE 80
CMD apachectl -D FOREGROUND

Make index.php and insert the following content to it.

<!DOCTYPE html>
<html>
<body>
<?php
date_default_timezone_set("Asia/Colombo");
echo "The time is " . date("h:i:sa");
?>
</body>
</html>

Docker Hub Account Setup

Go to https://hub.docker.com/signup

Create an account

Choose ‘Personal Plan’ (Continue with free) if asked

Create a Repository

Build a Docker image

docker build . -t <Docker Hub username>/<repository name>:v1

.

Share a Docker image

docker login -u <docker hub username>
docker push <docker hub username>/<respository name>:v1
docker logout

Now you can view the uploaded Docker image in your Docker Hub account.

Note: See TracWiki for help on using the wiki.