<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>2. Container Basics :: Kubernetes Labs</title><link>/2-container-basics/index.html</link><description>Kubernetes runs your applications in containers. In this chapter, you work with containers directly: you run them and build your own with Docker, and you describe a database with Docker Compose.
What You Learn By the end of this chapter, you can:
run, inspect, stop and remove a container package a Python script as an image with a Dockerfile describe a container, its configuration and its storage in a Compose file start and stop PostgreSQL on your machine and keep its data Sections Section In the lab 2.1. Containers Run nginx, then build and run an image with your own Python script 2.2. Docker Compose Start PostgreSQL from a Compose file and keep its data in a volume How the Labs Work All commands run with Docker on your machine. You don’t need a Kubernetes cluster until chapter 3. Each lab ends with optional tasks. If you finish early, go ahead with them. The following labs don’t depend on them. Prerequisites Docker is set up and verified as described in 1. Setup.</description><generator>Hugo</generator><language>en-us</language><atom:link href="/2-container-basics/index.xml" rel="self" type="application/rss+xml"/><item><title>2.1. Containers</title><link>/2-container-basics/1-containers/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/2-container-basics/1-containers/index.html</guid><description>In this lab, you run a ready-made container, then build and run an image with a Python script of your own.
Step 1: Run a Container Start the web server nginx in a container named web:
docker run -d --name web -p 8080:80 nginx:1.29 Docker prints the ID of the new container, a long random string. If the image isn’t on your machine yet, Docker downloads it first.</description></item><item><title>2.2. Docker Compose</title><link>/2-container-basics/2-docker-compose/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>/2-container-basics/2-docker-compose/index.html</guid><description>In this lab, you start PostgreSQL on your machine with Docker Compose and keep its data in a volume.
Step 1: Create a Compose File Create a directory for the files of this lab and change into it:
mkdir -p ~/labs/2.2 cd ~/labs/2.2 Create the file compose.yaml in ~/labs/2.2 with the following content:</description></item></channel></rss>