docker_ is being appended when creating container

Trey :

For some reason docker_ is being appended before repository image name. Here is docker-compose.yml:

version: '3.5'

services:

  mysql:
    container_name: mysql
    restart: always
    ports:
      - "3306:3306"
    build: ./db/mysql
    volumes:
      - type: volume
      name: mysql_volume
      source: ./db/mysql/data
      target: /var/lib/mysql

Dockerfile:

FROM mysql:latest AS mysql

ENV MYSQL_ROOT_PASSWORD=root
ENV MYSQL_USER=abc
ENV MYSQL_PASS=abc

EXPOSE 3306

CMD ["--default-authentication-plugin=mysql_native_password"]

Here is what docker images gives:

REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
docker_mysql            latest              b193d171468b        13 seconds ago      547MB
mysql                   latest              9b51d9275906        3 weeks ago         547MB

Whenever I delete all the images along with system prune and run docker-compose up, 2 images are formed and docker_ is being appeneded. I don't want interdependent images. Any pointers?

Burak Serdar :

docker-compose will use the last component of the directory containing docker-compose.yml as the project name, and add that to the image names it builds. You can run docker-compose with -p flag to change the project name.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=355888&siteId=1