如何通过将自定义补丁应用到文件而不创建状态为“已退出(0)”来创建自定义Docker映像

时间:2019-03-22 11:08:05

标签: docker docker-compose dockerfile customization docker-image

我正在使用PhpIPAM Docker映像,并且使用docker-compose运行我的容器(https://hub.docker.com/r/pierrecdn/phpipam)。我在Windows环境中。

这是我的docker-compose.yml

version: "3.3"

services:
    mysql:
        image: 'mysql:5.6'
        environment:
            - MYSQL_ROOT_PASSWORD=pass
        volumes:
            - 'D:/Docker/phpIPAM/mysql-db:/var/lib/mysql'
    ipam:
        depends_on:
            - mysql
        image: pierrecdn/phpipam
        environment:
            - MYSQL_ENV_MYSQL_USER=root
            - MYSQL_ENV_MYSQL_ROOT_PASSWORD=pass
            - MYSQL_ENV_MYSQL_HOST=mysql
        ports:
            - "6080:80"
            - "6025:25"
            - "6022:22"

当我启动命令时:

PS D:\Docker\phpIPAM> docker-compose up

一切正常,我的2个容器运行正常,可以在该应用程序上工作了。

1974e242966a        pierrecdn/phpipam   "docker-php-entrypoi…"   40 seconds ago      Up 38 seconds       0.0.0.0:6022->22/tcp, 0.0.0.0:6025->25/tcp, 0.0.0.0:6080->80/tcp   phpipam_ipam_1
6a638b4d1422        mysql:5.6           "docker-entrypoint.s…"   42 seconds ago      Up 39 seconds       3306/tcp                                                           phpipam_mysql_1

ow我想自定义PhpIPAM并将补丁应用到特定文件。实际上,我只是用已修补的映像替换了映像中的文件(请注意:该修补程序可以,我在运行的容器中对其进行了测试)。

因此,在新文件夹中,I-:

  1. 复制了我的PhpIPAM修补文件
  2. 复制并修改了我的docker-compose.yml文件以构建新映像
  3. 创建了一个名为“ phpipam2440”的docker文件,该操作可以将文件替换为新的补丁文件

这是我的新docker-compose.yml

version: "3.3"

services:
    mysql:
        image: 'mysql:5.6'
        environment:
            - MYSQL_ROOT_PASSWORD=pass
        volumes:
            - 'D:/Docker/phpIPAM/mysql-db:/var/lib/mysql'
    ipam2440:
        depends_on:
            - mysql
        build:
            context: .
            dockerfile: ./phpipam2440
        environment:
            - MYSQL_ENV_MYSQL_USER=root
            - MYSQL_ENV_MYSQL_ROOT_PASSWORD=pass
            - MYSQL_ENV_MYSQL_HOST=mysql
        ports:
            - "6080:80"
            - "6025:25"
            - "6022:22"
        tty: true

这是我的docker文件'phpipam2440'

FROM pierrecdn/phpipam 

ADD class.Common.php /var/www/html/functions/classes/

CMD ["echo","Patch Fix #2440 applied"]

现在我跑步

PS D:\Docker\phpIPAM\patch-2440> docker-compose up

这是结果

2e22a2de7d28        patch-2440_ipam2440   "docker-php-entrypoi…"   55 seconds ago      Exited (0) 53 seconds ago                       patch-2440_ipam2440_1
c65d2cd5eadf        mysql:5.6             "docker-entrypoint.s…"   56 seconds ago      Up 55 seconds               3306/tcp            patch-2440_mysql_1

我的自定义图片中的容器已“退出”,代码为0。

这意味着一切顺利,容器已经达到“必须完成的目的”。

但是我在docker-compose中使用了选项“ tty:true”,这将阻止我的容器退出。

我在做什么错了?

Thx

PS:有关信息,这是docker-compose命令的完整输出:

PS D:\Docker\phpIPAM\patch-2440> docker-compose up
Creating network "patch-2440_default" with the default driver
Building ipam2440
Step 1/3 : FROM pierrecdn/phpipam
 ---> 5385f0cfaf12
Step 2/3 : ADD class.Common.php /var/www/html/functions/classes/
 ---> b5e288da30ef
Step 3/3 : CMD ["echo","Patch Fix #2440 applied"]
 ---> Running in 6738048b3ae1
Removing intermediate container 6738048b3ae1
 ---> 989fdb6c8c8a

Successfully built 989fdb6c8c8a
Successfully tagged patch-2440_ipam2440:latest
WARNING: Image for service ipam2440 was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating patch-2440_mysql_1 ... done
Creating patch-2440_ipam2440_1 ... done
Attaching to patch-2440_mysql_1, patch-2440_ipam2440_1
mysql_1     | 2019-03-22 10:47:13 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
mysql_1     | 2019-03-22 10:47:13 0 [Note] mysqld (mysqld 5.6.43) starting as process 1 ...
mysql_1     | 2019-03-22 10:47:13 1 [Note] Plugin 'FEDERATED' is disabled.
mysql_1     | 2019-03-22 10:47:13 1 [Note] InnoDB: Using atomics to ref count buffer pool pages
mysql_1     | 2019-03-22 10:47:13 1 [Note] InnoDB: The InnoDB memory heap is disabled
mysql_1     | 2019-03-22 10:47:13 1 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
mysql_1     | 2019-03-22 10:47:13 1 [Note] InnoDB: Memory barrier is not used
mysql_1     | 2019-03-22 10:47:13 1 [Note] InnoDB: Compressed tables use zlib 1.2.11
mysql_1     | 2019-03-22 10:47:13 1 [Note] InnoDB: Using Linux native AIO
mysql_1     | 2019-03-22 10:47:13 1 [Note] InnoDB: Using CPU crc32 instructions
mysql_1     | 2019-03-22 10:47:13 1 [Note] InnoDB: Initializing buffer pool, size = 128.0M
mysql_1     | 2019-03-22 10:47:13 1 [Note] InnoDB: Completed initialization of buffer pool
ipam2440_1  | Patch Fix #2440 applied
mysql_1     | 2019-03-22 10:47:14 1 [Note] InnoDB: Highest supported file format is Barracuda.
mysql_1     | 2019-03-22 10:47:14 1 [Note] InnoDB: 128 rollback segment(s) are active.
mysql_1     | 2019-03-22 10:47:14 1 [Note] InnoDB: Waiting for purge to start
mysql_1     | 2019-03-22 10:47:14 1 [Note] InnoDB: 5.6.43 started; log sequence number 3398964
mysql_1     | 2019-03-22 10:47:14 1 [Note] Server hostname (bind-address): '*'; port: 3306
mysql_1     | 2019-03-22 10:47:14 1 [Note] IPv6 is available.
mysql_1     | 2019-03-22 10:47:14 1 [Note]   - '::' resolves to '::';
mysql_1     | 2019-03-22 10:47:14 1 [Note] Server socket created on IP: '::'.
mysql_1     | 2019-03-22 10:47:14 1 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
mysql_1     | 2019-03-22 10:47:14 1 [Warning] 'proxies_priv' entry '@ root@e1de09823bf2' ignored in --skip-name-resolve mode.
mysql_1     | 2019-03-22 10:47:14 1 [Note] Event Scheduler: Loaded 0 events
mysql_1     | 2019-03-22 10:47:14 1 [Note] mysqld: ready for connections.
mysql_1     | Version: '5.6.43'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)
patch-2440_ipam2440_1 exited with code 0

0 个答案:

没有答案