【问题标题】:docker desktop run automatically a container into an docker compose structuredocker desktop 自动将容器运行到 docker compose 结构中
【发布时间】:2022-11-16 00:31:43
【问题描述】:

每次我将 docker 桌面应用程序启动到 Windows 11 操作系统时,

它会自动将容器启动到 docker-compose 结构中。

但不是其他容器到这个 docker-compose 中。

我正在处理一个 MariaDB 容器......

我的 Apache 容器和我的 PHP 容器没有自动运行。只是 MariaDB

这是我的 docker-compose.yml 文件:

    version: '3'

services:

    apache:
        build: ./docker/apache
        container_name: projectx_apache
        tty: true
        ports:
            - '443:443'
        depends_on:
            - php
            - mariadb
        volumes:
            - ./:/var/www/projectx/

    php:
        build: ./docker/php
        container_name: projectx_php
        tty: true
        volumes:
            - ./:/var/www/projectx/

    mariadb:
        build: ./docker/mariadb
        container_name: projectx_mariadb
        restart: always
        tty: true
        environment:
            MYSQL_ROOT_PASSWORD: docker
            MYSQL_DATABASE: projectx
            MYSQL_USER: docker
            MYSQL_PASSWORD: docker
        ports:
            - '3306:3306'

这是我的 MariaDB 容器的 Dockerfile:

FROM mariadb:latest

ENV MYSQL_ROOT_PASSWORD docker
ENV MYSQL_DATABASE projectx
ENV MYSQL_USER root
ENV MYSQL_PASSWORD docker

RUN apt-get -y update
RUN apt-get -y install vim

EXPOSE 3310

CMD ["mysqld"]

这是我自动启动时的日志容器:

2022-11-15 14:16:33+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.9.4+maria~ubu2204 started.
2022-11-15 14:16:33+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-11-15 14:16:33+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.9.4+maria~ubu2204 started.
2022-11-15 14:16:34+00:00 [Note] [Entrypoint]: MariaDB upgrade not required
2022-11-15 14:16:34 0 [Note] mysqld (server 10.9.4-MariaDB-1:10.9.4+maria~ubu2204) starting as process 1 ...
2022-11-15 14:16:34 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-11-15 14:16:34 0 [Note] InnoDB: Number of transaction pools: 1
2022-11-15 14:16:34 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2022-11-15 14:16:34 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
2022-11-15 14:16:34 0 [Warning] mysqld: io_uring_queue_init() failed with ENOMEM: try larger memory locked limit, ulimit -l, or https://mariadb.com/kb/en/systemd/#configuring-limitmemlock under systemd (262144 bytes required)
2022-11-15 14:16:34 0 [Warning] InnoDB: liburing disabled: falling back to innodb_use_native_aio=OFF
2022-11-15 14:16:34 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
2022-11-15 14:16:34 0 [Note] InnoDB: Completed initialization of buffer pool
2022-11-15 14:16:34 0 [Note] InnoDB: File system buffers for log disabled (block size=4096 bytes)
2022-11-15 14:16:34 0 [Note] InnoDB: 128 rollback segments are active.
2022-11-15 14:16:34 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
2022-11-15 14:16:34 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
2022-11-15 14:16:34 0 [Note] InnoDB: log sequence number 1489638494; transaction id 8288
2022-11-15 14:16:34 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2022-11-15 14:16:34 0 [Note] Plugin 'FEEDBACK' is disabled.
2022-11-15 14:16:34 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
2022-11-15 14:16:34 0 [Note] Server socket created on IP: '0.0.0.0'.
2022-11-15 14:16:34 0 [Note] Server socket created on IP: '::'.
2022-11-15 14:16:34 0 [Note] mysqld: ready for connections.
Version: '10.9.4-MariaDB-1:10.9.4+maria~ubu2204'  socket: '/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
2022-11-15 14:16:34 0 [Note] InnoDB: Buffer pool(s) load completed at 221115 14:16:34

你知道为什么这个容器会自动启动吗?

【问题讨论】:

    标签: docker docker-compose mariadb


    【解决方案1】:

    这里自动启动的原因是MariaDB容器上的restart: always
    它会在 docker 守护进程重启时启动容器。看 restart policy

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-14
      • 1970-01-01
      • 2016-11-27
      • 2019-09-27
      相关资源
      最近更新 更多