0

I am using a PhpIPAM Docker image and I use docker-compose to run my containers (https://hub.docker.com/r/pierrecdn/phpipam). I'm in a Windows environment.

Here is my 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"

When I launch the command:

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

All is working fine, my 2 containers are correctly running and I can work on the app.

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

Now I would like to customize PhpIPAM and apply a patch to a specific file. Actually I just replace the file in the image by the patched one (note: the patch is ok, I tested it in a running container).

So in a new folder I-:

  1. copied my patched file of PhpIPAM
  2. copied and adapt my docker-compose.yml file to build the new image
  3. created a docker file named 'phpipam2440' with the operation to replace a file by my new patched file

Here is my new 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

and here is my docker file 'phpipam2440'

FROM pierrecdn/phpipam 

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

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

Now when I run

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

Here is the result

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

The container from my custom image is 'Exited' with code 0.

That mean all went well and the container has reach "the end of what it had to do".

However I used the option "tty: true" in my docker-compose and this should prevent my container to Exit.

What am I doing wrong ?

Thx

PS: For info here is the complete output of the docker-compose command:

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
Zou
  • 243
  • 2
  • 11
  • 2
    `CMD ["echo", ...]` explicitly tells Docker "instead of the thing you were doing before, when the container starts, print the message then exit". You probably mean `RUN` here. – David Maze Mar 22 '19 at 11:21
  • If you're just trying to inject a configuration file (not "patching" an existing file but replacing it or adding a new one), a `volumes:` bind mount could also be an easier setup than building a custom image. – David Maze Mar 22 '19 at 11:30
  • Thx @DavidMaze that's was my error! And it's not a configuration file but a php file with custom code in it. It will replace the original file. – Zou Mar 22 '19 at 13:29

0 Answers0