每次我將 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
你知道為什么這個容器會自動啟動嗎?
uj5u.com熱心網友回復:
這里自動啟動的原因是restart: always在MariaDB容器上,
它會在docker daemon重啟時啟動容器。查看
重啟策略
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/535522.html
