Skip to content

Commit

Permalink
Add Networking, Images, Persistence tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Varban Andreev committed May 4, 2020
1 parent 538d7bb commit c1d9bab
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Tasks/3.Networking/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Practice - networking

- Run an nginx container "nginx1" in detached mode
- Run a busybox container "busy1" in interactive mode
- Try to ping the nginx container by name (You won’t be able to)
- Create a custom network **newnet** with a bridge driver
- Run another detached nginx container "nginx2", this time using **newnet**
- Run a new interactive busybox container "busy2", again using **newnet**
- Try pinging the new nginx container by name
22 changes: 22 additions & 0 deletions Tasks/4.Building images/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Practice - building images

Your project utilizes microservices and Kuberenetes. On your cluster you have many containers (pods) with your services. There's a special container which runs Ubuntu and can access the other services' databases and other components. To access those components you install a few CLI tools on this special container. The problem - each time the cluster is re-deployed you must install the CLI tools again because they're not part of the container's base Ubuntu image.

You want to automate this process by building a Dockerfile for this container using ubuntu:18.04 as your base image.

To install those tools you normally use the following commands:

- $ `DEBIAN_FRONTEND=noninteractive` # Env var required for postgres
- $ `apt-get update && apt-get install -y postgresql` # Install postgres to access dbs
- $ `apt-get install -y wget` # Install wget for downloading software packages
- $ `apt-get install -y curl` # Install curl for running HTTP requests

:whale: HINT: Research how to set environment variables inside Dockerfiles for the DEBIAN_FRONTEND variable.

To build the image, navigate to your Dockerfile path and use
- `docker build –t "<name>:<tag>" .`

Run a container from this image in interactive mode and verify the installations:
- `psql --version` # You should see the psql version
- `wget --version` # You should see the wget version and other info
- `curl 'http://example.com'` # You should see some html
17 changes: 17 additions & 0 deletions Tasks/5.Using volumes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Practice - using volumes

Run a container "mypsql" using **postgres:12** with options to:
- run the container in detached mode
- pass an environment variable `POSTGRES_PASSWORD=secretpass`
- create a named volume with `-v <name>:/var/lib/postgresql/data`

Run a shell in the container and use psql to add a table and a record:
- $ `psql -U postgres`
- $ `create table public.films (id int PRIMARY KEY, name varchar(255));`
- $ `insert into films(id, name) values(1, 'Some movie');`

Exit the container and delete it. Run a new container with the same options. Use ***the same*** volume name to re-use the existing volume.

Run a shell inside the container and see if your data is still there:
- $ `psql –U postgres`
- $ `select * from public.films;`

0 comments on commit c1d9bab

Please sign in to comment.