---
# System prepended metadata

title: Docker 基本指令操作
tags: [docker, Docker]

---

---
lang: zh-tw
---

Docker 基本指令操作
===

#### :book: Docker Search for images

可以使用以下指令搜尋 Image (映像檔) 的詳細資訊與星星數 (熱門參考依據)
【via CMD to search and find images】:
```
> docker search nginx
```
```
※備註: docker search [images name]
```
```
NAME                              DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
nginx                             Official build of Nginx.                        11916               [OK]
jwilder/nginx-proxy               Automated Nginx reverse proxy for docker con…   1648                                    [OK]
richarvey/nginx-php-fpm           Container running Nginx + PHP-FPM capable of…   740                                     [OK]
linuxserver/nginx                 An Nginx container, brought to you by LinuxS…   75
bitnami/nginx                     Bitnami nginx Docker Image                      70                                      [OK]
tiangolo/nginx-rtmp               Docker image with Nginx using the nginx-rtmp…   51                                      [OK]
nginxdemos/hello                  NGINX webserver that serves a simple page co…   27                                      [OK]
jc21/nginx-proxy-manager          Docker container for managing Nginx proxy ho…   23
nginx/nginx-ingress               NGINX Ingress Controller for Kubernetes         22
jlesage/nginx-proxy-manager       Docker container for Nginx Proxy Manager        21                                      [OK]
schmunk42/nginx-redirect          A very simple container to redirect HTTP tra…   17                                      [OK]
blacklabelops/nginx               Dockerized Nginx Reverse Proxy Server.          12                                      [OK]
centos/nginx-18-centos7           Platform for running nginx 1.8 or building n…   11
centos/nginx-112-centos7          Platform for running nginx 1.12 or building …   10
nginxinc/nginx-unprivileged       Unprivileged NGINX Dockerfiles                  9
webdevops/nginx                   Nginx container                                 8                                       [OK]
nginx/nginx-prometheus-exporter   NGINX Prometheus Exporter                       6
sophos/nginx-vts-exporter         Simple server that scrapes Nginx vts stats a…   5                                       [OK]
1science/nginx                    Nginx Docker images that include Consul Temp…   5                                       [OK]
mailu/nginx                       Mailu nginx frontend                            3                                       [OK]
pebbletech/nginx-proxy            nginx-proxy sets up a container running ngin…   2                                       [OK]
travix/nginx                      NGinx reverse proxy                             2                                       [OK]
centos/nginx-110-centos7          Platform for running nginx 1.10 or building …   0
wodby/nginx                       Generic nginx                                   0                                       [OK]
ansibleplaybookbundle/nginx-apb   An APB to deploy NGINX                          0                                       [OK]
```

<br><br>

#### :book: Docker Pull for images

可以使用以下指令取得 Image (映像檔)
【via CMD to pull your images with tags】:
```
> docker pull nginx:latest
```
```
※備註: docker pull [images:tags]
```

<br><br>

#### :book: Docker Run Containers from images

可以使用以下指令透過 Image (映像檔) 建立與運行 Container (容器)
【via CMD to run a conainer from your images】:
```
> docker run -dit --name docker-nginx nginx:latest
```
```
※備註: docker run -dit --name [defined a name] [resource images:tags]
```
也可以透過綁定本地 Path (路徑) 與 Container (容器) 中的 Path (路徑) 進行同步
【set path for your volumes with container to sync】:

```
> docker run -dit --name docker-nginx -v C:/docker_server/app":/var/www/html nginx:latest
```
```
※備註: docker run -dit --name [defined a name] -v [localhost_path:containers path] [resource images:tags]
```
綁定 Network (網路) => <font color=#FF4040 size=3>需先建立一個網路</font>
【run with network】:

```
> docker run -dit --name docker-nginx -v C:/docker_server/app":/var/www/html --network web-network nginx:latest
```
```
※備註: docker run -dit --name [defined a name] -v [localhost_path:containers path] --network [defined a name] [resource images:tags] 
```

<br><br>

#### :book:Docker Creat a Network

可以使用以下指令建立一個 Network (網路), 後續可綁定於指定的 Container (容器)
【via CMD to create a network for your containers】:

```
> docker network create --driver bridge web-network
```
```
※備註: docker network create --driver bridge [defined a name]
```

<br><br>

#### :book:Docker Execute bash CMD

可以使用以下指令進入 Container (容器) 中, 直接進行 Linux Bash 指令操作
【via CMD into the Linux bash】:

```
> docker exec -it docker-nginx bash
```
```
※備註: docker exec -it [containers name] bash
```