# Creating 2 wordpress container with 1 database

**URL:** <https://forums.docker.com/t/creating-2-wordpress-container-with-1-database/140707>\
**Category:** Compose\
**Tags:** dockerhub, docker-compose\
**Created:** [April 5, 2024, 4:58pm UTC](https://forums.docker.com/t/creating-2-wordpress-container-with-1-database/140707 "2024-04-05T16:58:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![emmk0](https://avatars.discourse-cdn.com/v4/letter/e/cab0a1/32.png) [@emmk0](https://forums.docker.com/u/emmk0)\
**Post date:** [April 5, 2024, 4:58pm UTC](https://forums.docker.com/t/creating-2-wordpress-container-with-1-database/140707/1 "2024-04-05T16:58:19Z")

</div>

Hello. I’m new to docker and trying to learn. I’m wondering if it’s possible to run 2 different wordpress containers with different contents using 1 db service, ideally by modifying docker-compose.yml example file from [hub.docker.com](http://hub.docker.com)

```auto
version: '3.1'

services:

  wordpress:
    image: wordpress
    restart: always
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb
    volumes:
      - wordpress:/var/www/html

  db:
    image: mysql:8.0
    restart: always
    environment:
      MYSQL_DATABASE: exampledb
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - db:/var/lib/mysql

volumes:
  wordpress:
  db:

```

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [April 5, 2024, 8:10pm UTC](https://forums.docker.com/t/creating-2-wordpress-container-with-1-database/140707/2 "2024-04-05T20:10:49Z")

</div>

Yes, of course. You just need to choose different `WORDPRESS_DB_NAME` for both wordpress services, but then you need to precreate those before you start the wordpresse. Check the image description and you will find `WORDPRESS_TABLE_PREFIX` which can be changed and you can have multiple wordpresses in the same database.

[https://hub.docker.com/\_/wordpress](https://hub.docker.com/_/wordpress)
