# MySQL Con Docker-Compose

Luego de instalar Docker y Docker compose como se describe al inicio.

Fuente de este articulo

{% embed url="<https://medium.com/@chrischuck35/how-to-create-a-mysql-instance-with-docker-compose-1598f3cc1bee>" %}

procedemos a crear un archivo llamado docker-compose.xml

![](/files/-Mju900pgZRpKS0Kxjp3)

Este archivo tiene una configuración similar a la siguiente:

Cambie los nombre de la base de datos, los password y puertos,

```yaml
version: '3.3'
services:
  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_DATABASE: 'rigemdb'
      # So you don't have to use root, but you can if you like
      MYSQL_USER: 'avbravo'
      # You can use whatever password you like
      MYSQL_PASSWORD: 'denver16'
      # Password for root access
      MYSQL_ROOT_PASSWORD: 'denver16'
    ports:
      # <Port exposed> : < MySQL Port running inside container>
      - '3306:3306'
    expose:
      # Opens port 3306 on the container
      - '3306'
      # Where our data will be persisted
    volumes:
      - my-db:/var/lib/mysql
# Names our volume
volumes:
  my-db:
```

Para ejecutarlo utilice en el mismo directorio donde esta el archivo docker-compose.yml

```yaml
docker-compose up
```

Obtendremos una salida similar

![](/files/-Mju9kyWw0ds9GXD_xvv)

**ver contenedor**

```bash
docker ps -a
```

**detenerlo**

```bash
docker-compose stop
```

**removerlo**

```bash
docker-compose down
```


---

# 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://avbravo-2.gitbook.io/docker/mysql-con-docker-compose.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.
