Post

Building your first Dockerfile, Image, and Container

We spin up all types of containers on my channel in my tutorials, but we have yet to build our own custom Docker container image.Today we’ll start from scratch with an empty Dockerfile and create, build, and run our very own custom Docker image! We’ll learn all the commands that everyone should know when building and maintaining images with Docker.This tutorial is a great way to get started with Docker!

📺 Watch Video

Install Docker

To install docker, see this post

Docker commands

Source files

build image

1
docker build .

build image with tag

1
docker build -t hello-internet

list docker images

1
docker images

list docker containers

1
docker ps

list docker containers including stopped

1
docker ps -a

create container from image

1
docker run -d -p 80:80 <image id>

exec into running container

1
docker exec -it <container id> /bin/sh

stop running container

1
docker stop <container id>

start a stopped container

1
docker start <container id>

remove a container

1
docker rm <container id>

remove an image

1
docker rmi <image id>

⚙️ See all the hardware I recommend at https://l.technotim.live/gear

🚀 Don’t forget to check out the 🚀Launchpad repo with all of the quick start source files

This post is licensed under CC BY 4.0 by the author.