Git Product home page Git Product logo

dockercommands's Introduction

Docker Commands

  • Start Hello World Container

    docker run hello-world
  • List of Containers:

    docker ps
    docker ps -a
    • docker: This is the command-line interface (CLI) for interacting with the Docker engine.
    • ps: This is the Docker command for listing containers.
    • a: This is an optional flag that tells Docker to show all containers, including those that are not currently running.
  • List of Images:

    docker images
  • Search Images From Docker Hub:

    docker search  apache 
  • Pull Docker Image

    # apache image - latest by default
    docker pull httpd 
    
    # apache image - latest specified
    docker pull httpd:latest 
    
    #apache image - 2.9v
    docker pull httpd:2.9 
  • Start Docker Container

    # check container id using "docker ps -a"
    docker start container-id 
  • Stop Docker Container

    # check container id using "docker ps -a"
    docker stop container-id 
  • Run Docker Container

    # run container in terminal
    - docker run redis 
    
    # -d detached is used to run container in background of terminal
    - docker run -d redis 
    
    # -d detached is used to run container in background of terminal
    - docker run -d redis 
    
    # --name is used to specify a name for container
    - docker run -d --name mywebapp redis 
    
    # -p is port, 7000 is host port, 6379 is container port. Host port cant be same for multiple containers
    - docker run -p7000:6379 -d redis 
    • docker run is used to create a new container from an image, while docker start is used to start an existing container that has been stopped or paused.
  • Remove Docker Image

    docker rm image-name 
    
    # -f is used to forcefully delete image if its container is running
    docker rm -f image-name 
  • Remove Docker Container

    docker rm container-id 
    
    # -f is used to forcefully delete image if its container is running
    docker rm -f container-id 
  • Check Docker Logs

    - docker logs container-id
    - docker logs container-name
  • Connect with Container

    - docker exec -it container-id/container-name /bin/bash
    • In the docker exec command, the -it option is used to create an interactive terminal session inside a running container.
    • Bash is a powerful command-line interface that allows you to interact with the operating system and execute various commands and scripts. When you start a new instance of Bash within a container, you can use it to navigate the container's file system, install software, edit files, and perform other system-level tasks.
    • use β€œexit” to get out of container.
  • Command Manual:

    write man before any command to check possible flags that can be used with it.

    eg. man docker-images

dockercommands's People

Contributors

zuraizahmedshehzad avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.