Add Adminer to Docker
October 27, 2024 · AI Conversations
If you plan to add it to Docker later or in another environment, let me know so I can provide guidance on adding it to a Docker container.
Here's an example `docker-compose.yml`:
version: '3.8'
services:
db:
image: mysql:8.0
container_name: mysql_db
environment:
MYSQL_ROOT_PASSWORD: root_password
MYSQL_DATABASE: my_database
MYSQL_USER: user
MYSQL_PASSWORD: user_password
volumes:
- db_data:/var/lib/mysql
ports:
- "3306:3306"
adminer:
image: adminer:latest
container_name: adminer
ports:
- "8080:8080"
depends_on:
- db
volumes:
db_data:
### Explanation of the Setup
– **Database Service (`db`)**:
– Uses the official MySQL image.
– Sets environment variables for MySQL root password, database name, username, and user password.
– Exposes MySQL on port `3306` (you can change this if needed).
– **Adminer Service (`adminer`)**:
– Uses the Adminer image.
– Exposes Adminer on port `8080` (so you can access it at `http://localhost:8080`).
### Usage
1. Save this file as `docker-compose.yml`.
2. Run the services with:
docker-compose up -d
3. You can then access Adminer in your browser at `http://localhost:8080`.
Let me know if you have any custom configurations or additional requirements!
Here's an example `docker-compose.yml`:
version: '3.8'
services:
db:
image: mysql:8.0
container_name: mysql_db
environment:
MYSQL_ROOT_PASSWORD: root_password
MYSQL_DATABASE: my_database
MYSQL_USER: user
MYSQL_PASSWORD: user_password
volumes:
- db_data:/var/lib/mysql
ports:
- "3306:3306"
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
container_name: phpmyadmin
environment:
PMA_HOST: db
PMA_USER: user
PMA_PASSWORD: user_password
PMA_PORT: 3306
ports:
- "8080:80"
depends_on:
- db
volumes:
db_data:
### Explanation of the Setup
– **Database Service (`db`)**:
– Uses the official MySQL image.
– Sets environment variables for MySQL root password, database name, username, and user password.
– Exposes MySQL on port `3306`.
– **phpMyAdmin Service (`phpmyadmin`)**:
– Uses the phpMyAdmin image.
– Configures phpMyAdmin to connect to the `db` service with the specified MySQL user credentials.
– Exposes phpMyAdmin on port `8080`, so you can access it at `http://localhost:8080`.
### Usage
1. Save this file as `docker-compose.yml`.
2. Run the services with:
docker-compose up -d
3. You can then access phpMyAdmin in your browser at `http://localhost:8080`.
Let me know if you need any additional configurations or adjustments!