# 25.10、Docker-Compose 转换 docker run

## mssql

### docker run 方式

```bash
docker run --name first-mssql -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=APJ.com!q1w2e3' -e 'MSSQL_PID=Express' -p 1433:1433 -d mcr.microsoft.com/mssql/server
```

### docker-compose 方式

```yaml
version: '3.4'

services: 
  first-mssql:
    container_name: first-mssql
    environment: 
      - ACCEPT_EULA=Y
      - SA_PASSWORD=APJ.com!q1w2e3
      - MSSQL_PID=Express
    ports: 
      - 1433:1433
    image: mcr.microsoft.com/mssql/server
```

## mysql

### docker run 方式

```bash
docker run --name first-mysql -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 -d mysql
```

### docker-compose 方式

```yaml
  first-mysql:
    container_name: first-mysql
    environment: 
      - MYSQL_ROOT_PASSWORD=123456
    ports: 
      - 3306:3306
    image: mysql
```

## nginx

### docker run 方式

```bash
docker run --name first-nginx -p 8081:80 -d nginx
```

### docker-compose 方式

```yaml
  first-nginx:
    container_name: first-nginx
    ports: 
      - 8081:80
    image: nginx
```

## **最终配置**

```yaml
version: '3.4'

services: 
  first-mssql:
    container_name: first-mssql
    environment: 
      - ACCEPT_EULA=Y
      - SA_PASSWORD=APJ.com!q1w2e3
      - MSSQL_PID=Express
    ports: 
      - 1433:1433
    image: mcr.microsoft.com/mssql/server

  first-mysql:
    container_name: first-mysql
    environment: 
      - MYSQL_ROOT_PASSWORD=123456
    ports: 
      - 3306:3306
    image: mysql

  first-nginx:
    container_name: first-nginx
    ports: 
      - 8081:80
    image: nginx
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://monksoul.gitbook.io/hoa/dockerrongqihua/dockercomponsetodockerrun.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
