Docker Cheatsheet for DevOps:

Docker Cheatsheet  for DevOps:

Here's a Docker cheatsheet tailored for DevOps tasks:

  1. Images:

    • Build an image from a Dockerfile: docker build -t <image-name> <path-to-dockerfile>

    • Tag an image: docker tag <image-id> <new-repo>:<tag>

  2. Containers:

    • Run a detached container with a specific name: docker run -d --name <container-name> <image-name>

    • Run a container with environment variables: docker run -e VAR_NAME=var_value <image-name>

    • View container logs: docker logs <container-id>

    • Inspect container details: docker inspect <container-id>

  3. Networking:

    • Expose a port when running a container: docker run -p <host-port>:<container-port> <image-name>

    • Create a custom bridge network: docker network create --driver bridge <network-name>

    • Connect a container to multiple networks: docker network connect <network-name> <container-id>

  4. Volumes:

    • Mount a host directory into a container: docker run -v /host/path:/container/path <image-name>

    • Mount a named volume: docker run -v <volume-name>:/container/path <image-name>

  5. Docker Compose:

    • Specify Docker Compose file: docker-compose -f <docker-compose-file> up

    • Scale services with Docker Compose: docker-compose up --scale <service-name>=<num-instances>

    • Stop and remove containers, networks, and volumes: docker-compose down

  6. Registry:

    • Push image to Docker Hub: docker push <image-name>

    • Push image to a private registry: docker push <registry-url>/<image-name>:<tag>

    • Pull image from a private registry: docker pull <registry-url>/<image-name>:<tag>

  7. Swarm (Orchestration):

    • Initialize a Docker Swarm: docker swarm init

    • Join a node to a Swarm: docker swarm join --token <token> <manager-ip>:<manager-port>

    • Deploy a service in Swarm: docker service create --name <service-name> <image-name>

  8. Miscellaneous:

    • Prune unused resources: docker system prune -a

    • Check Docker version: docker version

    • Monitor resource usage: docker stats <container-id>

Day 20 of #90daysofDevOps

Thanks for reading

Follow me for more about DevOps♾️........

________________________________________________________________________________

#90daysHardChallenge

#Cloudcomputing

#DevOps

#Python

#TrainWithShubham