Docker-composer ERROR: Cannot start service db: OCI runtime create failed: container with id exists

  docker, docker-compose

The first time I run docker-compose up, docker creates the components, yet, after rebooting when I just want to start the container and I run docker-compose start I get the following error:

ERROR: for mysqldb  Cannot start service db: OCI runtime create failed: container with id exists: xxxxxxx

If I delete the container and I run docker-compose up again it works, but every time I restart the computer I have to re-create the container, why is that? In the past I was able to mount the containers by running docker-compose start, whereas now it seems I have to recreate them every time.

I created the following docker-composer.yml:

version: '3.3'

services:
  # Database
  db:
    image: mysql:5.7
    container_name: mysqldb
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      DB_HOST: localhost
      MYSQL_ROOT_PASSWORD: testing
      MYSQL_DATABASE: testing
      MYSQL_USER: root
      MYSQL_PASSWORD: testing
    networks:
      - testingnetwork
    ports:
      - "3307:3306"
  # phpmyadmin
  phpmyadmin:
    depends_on:
      - db
    image: phpmyadmin/phpmyadmin
    container_name: phpmyadmin
    restart: always
    ports:
      - '8181:80'
    environment:
      PMA_HOST: db
      MYSQL_ROOT_PASSWORD: testing
    networks:
      - testingnetwork
  # WordPress
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - '8080:80'
    restart: always
    container_name: testing_wordpress
    volumes: 
      - ./public/:/var/www/html      
    environment:
      WORDPRESS_DB_NAME: testing
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: testing
      WORDPRESS_CONFIG_EXTRA: define('WP_ALLOW_MULTISITE', true );
    hostname: testing.org.local
    labels:
       com.theimpossiblecode.expose.domain: "testing.org.local"
       com.theimpossiblecode.expose.domainIsHost: "true"
    networks:
      testingnetwork:
          aliases:
            - testing.org.local
networks:
  testingnetwork:
volumes:
  db_data:

Source: Docker Questions

LEAVE A COMMENT