Skip to content

Instantly share code, notes, and snippets.

@NileshPatel17
Last active October 1, 2021 08:07
Show Gist options
  • Save NileshPatel17/e03a72d8689bab4b2d015f6c7753f6eb to your computer and use it in GitHub Desktop.
Save NileshPatel17/e03a72d8689bab4b2d015f6c7753f6eb to your computer and use it in GitHub Desktop.

Revisions

  1. NileshPatel17 revised this gist Oct 1, 2021. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion useful-docker-commands.md
    Original file line number Diff line number Diff line change
    @@ -30,4 +30,10 @@ docker exec -i -t -u root /bin/bash
    Remove all unused containers, volumes, networks and images
    ```javascript
    docker system prune -a --volumes
    ```
    ```

    view container log
    ```
    docker logs -f 49725ba5da0f
    ```
    -f, --follow Follow log output
  2. NileshPatel17 revised this gist Jul 23, 2021. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions useful-docker-commands.md
    Original file line number Diff line number Diff line change
    @@ -23,3 +23,11 @@ bash shell with root if container is running in a different user context
    ```javascript
    docker exec -i -t -u root /bin/bash
    ```
    delete all containers including its volumes use
    ```javascript
    docker rm -vf $(docker ps -a -q)
    ```
    Remove all unused containers, volumes, networks and images
    ```javascript
    docker system prune -a --volumes
    ```
  3. NileshPatel17 revised this gist Jul 23, 2021. 1 changed file with 25 additions and 7 deletions.
    32 changes: 25 additions & 7 deletions useful-docker-commands.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,25 @@
    ### docker commands:
    kill all running containers with docker kill $(docker ps -q)
    delete all stopped containers with docker rm $(docker ps -a -q)
    delete all images with docker rmi $(docker images -q)
    update and stop a container that is in a crash-loop with docker update --restart=no && docker stop
    bash shell into container docker exec -i -t /bin/bash - if bash is not available use /bin/sh
    bash shell with root if container is running in a different user context docker exec -i -t -u root /bin/bash
    # Docker commands:
    kill all running containers
    ```javascript
    docker kill $(docker ps -q)
    ```
    delete all stopped containers
    ```javascript
    docker rm $(docker ps -a -q)
    ```
    delete all images
    ```javascript
    docker rmi $(docker images -q)
    ```
    update and stop a container that is in a crash-loop
    ```javascript
    docker update --restart=no && docker stop
    ```
    bash shell into container (if bash is not available use /bin/sh)
    ```javascript
    docker exec -i -t /bin/bash
    ```
    bash shell with root if container is running in a different user context
    ```javascript
    docker exec -i -t -u root /bin/bash
    ```
  4. NileshPatel17 revised this gist Jul 23, 2021. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion useful-docker-commands.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,7 @@
    ‎‎​
    ### docker commands:
    kill all running containers with docker kill $(docker ps -q)
    delete all stopped containers with docker rm $(docker ps -a -q)
    delete all images with docker rmi $(docker images -q)
    update and stop a container that is in a crash-loop with docker update --restart=no && docker stop
    bash shell into container docker exec -i -t /bin/bash - if bash is not available use /bin/sh
    bash shell with root if container is running in a different user context docker exec -i -t -u root /bin/bash
  5. NileshPatel17 created this gist Jul 23, 2021.
    1 change: 1 addition & 0 deletions useful-docker-commands.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    ‎‎​