Docker and Kubernetes
Run, debug and clean up containers. 21 commands.
- Open a shell inside a running containerGet a terminal inside a Docker container to look around, check files or debug.
- Install DockerDocker and Docker Compose, ready to run containers.
- Docker Compose: start, stop, rebuild and logsThe everyday Docker Compose commands, run from the folder with docker-compose.yml.
- Copy files into and out of a containerMove a file between your computer and a running container with docker cp.
- Find a container's IP addressLook up the IP address Docker gave a container.
- Fix "port is already allocated" in DockerSomething else, often an old container, is already using the port. Find it and stop it or pick another port.
- Fix Docker "permission denied" and "Cannot connect to the Docker daemon"Docker commands fail because Docker isn't running, or your user isn't allowed to use it.
- Free up Docker disk spaceDocker quietly fills your disk with old images, containers and build cache. Here's how to see it and clear it.
- Install kubectlThe command-line tool for talking to any Kubernetes cluster.
- Install PodmanA free Docker alternative that runs containers without a background daemon.
- List pods, read their logs and delete a stuck oneThe everyday kubectl commands: see your pods, read what they printed, find out why one crashed and restart it.
- List, stop and restart Docker containersSee which containers are running, then stop, start or restart one by name.
- Move a Docker image to another machineSave an image to a file and load it elsewhere, without pushing it to a registry.
- Pass environment variables to a containerGive a container settings like API URLs and keys, one at a time or from a .env file.
- Reach your computer's localhost from inside a containerInside a container, localhost means the container itself. Use host.docker.internal to reach your own machine.
- Rebuild a Docker image from scratchForce Docker to rebuild every step, ignoring its cache, when changes aren't showing up.
- Run Kubernetes locally with kindA real Kubernetes cluster running inside Docker on your own machine, for testing.
- Run PostgreSQL in DockerA local Postgres database in one command, with its data kept safe between restarts.
- See a container's logsRead what a container printed, follow it live or see only the latest lines.
- Stop and remove all containers and imagesClear out every container, and optionally every image, for a clean start.
- Update DockerGet the latest Docker Desktop or Docker Engine.