Urgent.News

What's breaking now, across thousands of outlets.

Tech

Kubernetes - Day - 04 - Docker Commands

IMAGES docker images alpine images & bookworm images ( these are like families ) --> these are small images to be used for 10 mb application rather than going for bigger version of OS. docker pull ubuntu:noble-20260810 docker ps [ process status ] ps aux [ process which are running currenlty ] docker ps [ currently running containers ] docker ps -a [ provides the list of images which are Exited ]…

On day four of exploring Kubernetes and Docker, we delve into essential Docker commands. These commands are crucial for managing Docker images, containers, networks, volumes, and compose files.

To begin, we can list all Docker images with the command `docker images alpine images & bookworm images`. These images are akin to families, representing small images suitable for applications under 10MB instead of opting for larger OS versions.

To inspect running processes, we use `docker ps` for the current status and `ps aux` for processes currently running. The command `docker ps` displays containers that are currently active, while `docker ps -a` lists all containers, including those that have exited.

To remove exited containers, we execute `docker rm $(docker ps -aq)`. This command removes all containers that are not running.

When we initiate a new container, such as `docker run ubuntu`, it exits immediately since it doesn't have an entry point. To run a command within a container, we use `docker run -d ubuntu bash`. Conversely, `docker run -it ubuntu bash` allows us to interact with the container's shell.

To execute commands within a running container, we use `docker exec -it container_id bash`. For instance, `docker run -it ubuntu sleep 10` causes the container to display 11 characters in its ID upon completion.

Redis and Postgres are applications running on base OSes. The key directives for these containers include entry-point, command, and expose. For example, `docker run -d ubuntu bash` sets up an interactive bash session, enabling us to explore the container's environment.

To run a specific container, we use `docker run -d --name webapp-nginx nginx`. The container will be accessible on port 80 by default. To access the container's shell, we execute `docker exec -it container_id bash`. After exiting the container, we can stop it using `docker stop container_id` or `docker stop name`.

By default, containers expose their ports to the host, allowing us to access services running within the container. We can log container output in real-time with `docker logs -f container_id` or `docker logs -f name`. To terminate a container, issue `docker stop container_id` or `docker stop name`.

To map ports from the container to the host, we use `docker run -d --name webapp -p 8090:80 nginx`. This configuration exposes the container's port 80 to the host's port 8090. For a more permanent setup, we can bind mounts a directory using `docker run --rm -d --name webapp -p 8090:80 -v ./html:/usr/share/nginx/html nginx`. This command binds the local `./html` directory to the container's `/usr/share/nginx/html` path. When the container is stopped, Docker automatically deletes it due to the `--rm` flag.

To retrieve container details, including its assigned private IP, we use `docker inspect container_id`. This information enables us to access the container's web page via `curl http://private_ip:80` from within the host. For external access, we can use the host's URL, such as `curl http://localhost:80` or `curl http://localhost:8090`.

In summary, mastering these Docker commands empowers us to efficiently manage images, containers, networks, volumes, and compose files within a Kubernetes environment.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

How I Turned an Old Broken Laptop Into a Silent $0 Home Server That Safely Backs Up Every Device in My House in 2026

How I Turned an Old Broken Laptop Into a Silent $0 Home Server That Safely Backs Up Every Device in My House in 2026 Transforming an idle piece of hardware into a high-utility node is one of the most…

  • Author repurposes 8-year-old Dell XPS 13 laptop into silent home server
  • Laptop's broken screen, dead battery, and slow OS inconsequential for project
  • Intel Core i5 processor provides powerful foundation for server operations

Industrial Protocols on the Open Internet: A ZoomEye Measurement of Modbus and EtherNet/IP

Industrial Protocols on the Open Internet: A ZoomEye Measurement of Modbus and EtherNet/IP Industrial control protocols were designed for isolated networks.

  • Modbus protocol dominates with 9,820 records, primarily from Cyprus
  • EtherNet/IP protocol shows even distribution with 585 records, mainly from the US
  • Siemens S7 protocol is least distributed with 173 records, mostly from Germany

More from Monday 21 September →