Skip to content

Instantly share code, notes, and snippets.

@zmts
Last active March 27, 2026 06:36
Show Gist options
  • Select an option

  • Save zmts/509f224950f85f3cfe4365e2b80081d1 to your computer and use it in GitHub Desktop.

Select an option

Save zmts/509f224950f85f3cfe4365e2b80081d1 to your computer and use it in GitHub Desktop.

Revisions

  1. zmts revised this gist Jun 25, 2020. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -99,6 +99,13 @@ Delete all stopped containers:
    docker rm $(docker ps -a -q)
    ```

    ### Other

    Install help utils
    ```
    apt-get install iputils-ping nmap
    ```

    Jump into container shell
    ```
    docker exec -it CONTAINER_ID /bin/sh
  2. zmts revised this gist Jun 25, 2020. 1 changed file with 12 additions and 8 deletions.
    20 changes: 12 additions & 8 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -51,6 +51,8 @@ CMD [ "node", "./dist/main.js" ]

    ## Docker commands

    ### Images

    Build docker image
    ```
    docker build -t test-image-name .
    @@ -75,24 +77,26 @@ Remove all images at once
    docker rmi $(docker images -q)
    ```

    Stop all running containers
    ### Containers

    List all active containers
    ```
    docker stop $(docker ps -a -q)
    docker ps
    ```

    Delete all stopped containers:
    List all active and dead containers
    ```
    docker rm $(docker ps -a -q)
    docker ps -a
    ```

    List all active containers
    Stop all running containers
    ```
    docker ps
    docker stop $(docker ps -a -q)
    ```

    List all active and dead containers
    Delete all stopped containers:
    ```
    docker ps -a
    docker rm $(docker ps -a -q)
    ```

    Jump into container shell
  3. zmts revised this gist Jun 25, 2020. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -70,6 +70,11 @@ List all images
    docker image ls
    ```

    Remove all images at once
    ```
    docker rmi $(docker images -q)
    ```

    Stop all running containers
    ```
    docker stop $(docker ps -a -q)
    @@ -80,11 +85,6 @@ Delete all stopped containers:
    docker rm $(docker ps -a -q)
    ```

    Remove all images at once
    ```
    docker rmi $(docker images -q)
    ```

    List all active containers
    ```
    docker ps
  4. zmts revised this gist Jun 25, 2020. 1 changed file with 19 additions and 0 deletions.
    19 changes: 19 additions & 0 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -65,6 +65,25 @@ Or run image in silent(daemon) mode
    ```
    docker run -d -p 7777:7777 test-image-name
    ```
    List all images
    ```
    docker image ls
    ```

    Stop all running containers
    ```
    docker stop $(docker ps -a -q)
    ```

    Delete all stopped containers:
    ```
    docker rm $(docker ps -a -q)
    ```

    Remove all images at once
    ```
    docker rmi $(docker images -q)
    ```

    List all active containers
    ```
  5. zmts revised this gist Dec 2, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@
    ```
    "scripts": {
    "build": "tsc",
    "start": "NODE_ENV=production node ./dist/main.js"
    "start": "node ./dist/main.js"
    }
    ```

    @@ -46,7 +46,7 @@ RUN npm run build
    EXPOSE 7777
    CMD [ "npm", "start" ]
    CMD [ "node", "./dist/main.js" ]
    ```

    ## Docker commands
  6. zmts created this gist Nov 27, 2019.
    82 changes: 82 additions & 0 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,82 @@
    # Docker, TypeScript, Node.js

    ## Preconditions:
    - TS application listening port: 7777

    ```
    |-- dist
    |-- src
    |-- .dockerignore
    |-- Dockerfile
    |-- package.json
    |-- package-lock.json
    `-- tsconfig.json
    ```

    `package.json` scripts
    ```
    "scripts": {
    "build": "tsc",
    "start": "NODE_ENV=production node ./dist/main.js"
    }
    ```

    ## Dockerfile

    ```
    FROM node:10-alpine
    # update packages
    RUN apk update
    # create root application folder
    WORKDIR /app
    # copy configs to /app folder
    COPY package*.json ./
    COPY tsconfig.json ./
    # copy source code to /app/src folder
    COPY src /app/src
    # check files list
    RUN ls -a
    RUN npm install
    RUN npm run build
    EXPOSE 7777
    CMD [ "npm", "start" ]
    ```

    ## Docker commands

    Build docker image
    ```
    docker build -t test-image-name .
    ```

    Run image in interactive mode
    ```
    docker run -it -p 7777:7777 test-image-name
    ```

    Or run image in silent(daemon) mode
    ```
    docker run -d -p 7777:7777 test-image-name
    ```

    List all active containers
    ```
    docker ps
    ```

    List all active and dead containers
    ```
    docker ps -a
    ```

    Jump into container shell
    ```
    docker exec -it CONTAINER_ID /bin/sh
    ```