docker
TLDR
Run container
SYNOPSIS
docker command [options]
DESCRIPTION
docker is a platform for developing, shipping, and running applications in containers. It packages applications with dependencies into standardized units, ensuring consistency across different environments.
The tool has revolutionized application deployment and development workflows.
PARAMETERS
run [options] image
Create and start containerps [-a]
List containersbuild -t name path
Build image from Dockerfilepull image
Pull image from registrypush image
Push image to registryexec container command
Execute command in running containerlogs container
Fetch container logsstop container
Stop running containerstart container
Start stopped containerrm container
Remove containerrmi image
Remove imageimages
List images
RUN OPTIONS
-d, --detach
Run in background-it
Interactive with TTY-p host:container
Publish port-v host:container
Mount volume--name name
Assign name to container-e var=value
Set environment variable--rm
Automatically remove on exit--network network
Connect to network
WORKFLOW
docker run -d -p 80:80 --name webserver nginx
# Interactive container
docker run -it ubuntu bash
# With environment variables
docker run -e DATABASE_URL=postgres://... myapp
# With volume mount
docker run -v $(pwd):/app -w /app node npm install
# Build image
docker build -t myapp:latest .
# Push to registry
docker tag myapp:latest user/myapp:latest
docker push user/myapp:latest
# View logs
docker logs -f container_name
# Execute command
docker exec -it container_name bash
# Clean up
docker stop container_name
docker rm container_name
docker rmi image_name
DOCKERFILE
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]
COMMON OPERATIONS
docker ps
# List all containers
docker ps -a
# List images
docker images
# Remove all stopped containers
docker container prune
# Remove unused images
docker image prune
# System-wide cleanup
docker system prune -a
# Inspect container
docker inspect container_name
# Container stats
docker stats
CAVEATS
Requires Docker daemon running. Root or docker group membership needed. Networking can be complex. Volume permissions issues common. Images can be large. Security considerations for production. Different behavior on different operating systems.
HISTORY
Docker was created by Solomon Hykes at dotCloud in 2013, becoming open-source and revolutionizing application containerization.
SEE ALSO
docker-compose(1), podman(1), kubectl(1)


