What is Docker?
Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications.
Installing Docker sets up Docker Engine (background daemon managing containers like VMs) and CLI (interacts via API; other tools use it too).
Running Your First Container
Echo test:
docker run busybox echo "hello world"
- docker run: Starts container from image.
- busybox: Minimal Linux image; echo outputs message. Pulls if absent; runs once, exits.
Interactive:
docker run -it busybox
- -it: -i (stdin connect) + -t (pseudo-terminal).
- Shell access; exit stops/removes.
Packages count:
dpkg -l | wc -l
- dpkg -l: Lists Debian packages.
- | wc -l: Counts lines (minimal: <100).
Dive Deeper: Ubuntu Container with figlet
Launch:
docker run -it ubuntu
- Pulls Ubuntu image.
- -it: Interactive root shell (bare-bones system).
Install:
apt-get update
apt-get install figlet
- update: Refreshes repos.
- install: Adds figlet (ASCII art); root skips sudo.
Test:
figlet hello
- Prints "HELLO" art; install if missing—shows isolation.
Key Takeaways
Containers isolate/reproduce envs. Start with docker run. Experiment, exit to clean. Next: Images/volumes.
Top comments (0)