Admin User
June 01, 2025 11:49 AM · 5 min read
Docker simplifies app deployment by packaging code and dependencies into portable containers. It’s widely used for both development and production environments due to its consistency and efficiency.
bash
sudo apt remove docker docker-engine docker.io containerd runc
bash
sudo apt update sudo apt install apt-transport-https ca-certificates curl software-properties-common
bash
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
bash
echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] \ https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
bash
sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io
bash
sudo docker --version sudo docker run hello-world
bash
docker pull nginx docker pull node
Browse: https://hub.docker.com
Create a Dockerfile
:
Dockerfile
# For Node.js app FROM node:18 WORKDIR /app COPY . . RUN npm install CMD ["npm", "start"] EXPOSE 3000
Then build it:
bash
docker build -t my-node-app .
CommandDescriptiondocker ps
Show running containersdocker images
List local imagesdocker exec -it <id> bash
Enter running containerdocker stop <id>
Stop a containerdocker rm <id>
Remove a containerdocker rmi <id>
Remove an image
project-root/ ├── backend/ │ └── Dockerfile ├── frontend/ │ └── Dockerfile └── docker-compose.yml
docker-compose.yml
:yaml
version: '3' services: frontend: build: ./frontend ports: - "3000:3000" depends_on: - backend backend: build: ./backend ports: - "5000:5000" environment: - NODE_ENV=production
bash
docker-compose up --build
Docker Compose automatically creates a default network.
Services can communicate using their service name (frontend
, backend
) as hostname.
Example: Your frontend can make an API call to http://backend:5000/api
.
You now know how to:
Install Docker on Ubuntu LTS
Use Docker images and containers
Build custom images
Deploy full-stack apps using Docker Compose
Utilize Docker networking for internal communication
Docker is an essential tool for modern DevOps and deployment workflows. Master it once, and you’ll level up your development and deployment pipeline.