Skip to content

patricekrakow/play-with-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Let's Play with Docker

As usual, let's go to https://killercoda.com/playgrounds/scenario/ubuntu to get an Ubuntu machine (for 60 minutes).

Prompt Customization

That's just a question of taste, but I like to cutomize my prompt first.

You can edit the .bashrc file:

vi .bashrc

and add the following lines at the end:

# Added by PK
export PS1="\[\e[32m\]\h\[\e[m\]:\w\\$ "

Then, you can execute the command to see the result in all terminal connections:

source .bashrc

Installation

Check the current version of Docker:

docker --version

Uninstall old/unofficial version

sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc podman-docker containerd runc | cut -f1)

Install using the apt repository

Add Docker's official GPG key

sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

Add the repository to Apt sources:

sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt update

Install the latest Docker packages

sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

You can answer Y (Yes) to all the questions ;-)

Check if the Docker deamon is running:

sudo systemctl status docker

if not, you can start it with:

sudo systemctl start docker

If you get the following error message:

Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xeu docker.service" for details.

just wait a few seconds and retry.

Verify the Installation

Finally, you can verify that the installation is successful by running the hello-world image:

sudo docker run hello-world

If you are not using Killercoda, it might interestting to continue the installation with Manage Docker as a non-root user.

Introduction

You can now follow the hands-on guide Develop with containers and use the workaround from Let's Play with Killercode to expose the HTTP service running just on localhost to 0.0.0.0 as required by Killercoda.

You can use the following NGINX configuration:

events {
  worker_connections 768;
}

http {
  server {
    listen 0.0.0.0:8080;

    location / {
      proxy_pass http://localhost:80/;
    }

  }
}

and you will have to (re-)start NGINX as default configuration would have failed because the application from the Docker hands-on guide is already using the port 80.

Reference

About

Let's Play with Docker

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors