Getting Started with Docker for Developers
Docker has become essential for modern development. Let's get started!
What is Docker?
Docker is a platform for developing, shipping, and running applications in containers.
Basic Commands
``
bash
Build an image
docker build -t myapp .
Run a container
docker run -p 3000:3000 myapp
List containers
docker ps
`
Dockerfile Example
`dockerfile
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
`
Docker Compose
`yaml
version: '3.8'
services:
web:
build: .
ports:
"3000:3000" db:
image: postgres:15
``Conclusion
Docker simplifies deployment and ensures consistency across environments!