CodeIgniter Forums
Codeigniter 4 and Docker - Printable Version

+- CodeIgniter Forums (
+-- Forum: CodeIgniter 4 (
+--- Forum: CodeIgniter 4 Support (
+--- Thread: Codeigniter 4 and Docker (/showthread.php?tid=74460)

Pages: 1 2

Codeigniter 4 and Docker - andybiancoblu - 09-26-2019

Hi everyone.

Just finished to try Codeigniter 4 in a Docker container, and I have to say I'm really surprised there's no mention of such technology in the documentation.
I have some points and I'd like to hear your opinion

1) Composer install DOESN'T work out of the box. I find it really surprising because that tool is intended to simplify tasks, not to spend time troubleshooting.

2)Why encoraging people to develop on php local server (spark) installing dependencies and making system "dirty"?

3)What was so wrong with Manual Install? With manual install I was able to get at least the welcome message. Controllers subfolders separation didn't work, and that's a major issue IMO.

I suggest we all start to seriously consider Docker enviroment as a primary alternative, cause it's safe and also realiable for local dev. Not to mention that, once finished, u can create your own images to send in a CI/CD context.

Hope you all get the "constructive" side of my post and would like to give me a feedback, or maybe start to have ideas to implement such great  tech as Docker.

RE: Codeigniter 4 and Docker - ciadmin - 09-26-2019

Manual install is still an option (
Composer install of the appstarter works out of the box, as far as we know. Which composer install are you referring to?
RUnning the local (spark) server is an *option* for those who don't want to configure their server.

"Docker" is coming, this quarter Smile

RE: Codeigniter 4 and Docker - engel - 11-18-2019

I can testify that composer works out of the box.

RE: Codeigniter 4 and Docker - - 12-22-2019

Can you share your Dockerfile?

RE: Codeigniter 4 and Docker - InsiteFX - 12-23-2019

Controllers and sub folders separation doe's work as long as you namespace them right.

RE: Codeigniter 4 and Docker - atsanna - 12-29-2019

If you wish, you can use this basic example to create your container (tested on Ubuntu 18.04 - Docker version 19.03.5, build 633a0ea838):

1) create this structure

codeigniter /
    - conf / apache.conf
    - Dockerfile

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "/var/www/html/codeigniter4/public"
    ServerName localhost
    <Directory "/var/www/html/codeigniter4/public/">
        AllowOverride all


FROM php:7.2.26-apache

RUN apt-get update
RUN apt-get upgrade -y

RUN apt-get install --fix-missing -y libpq-dev
RUN apt-get install --no-install-recommends -y libpq-dev
RUN apt-get install -y libxml2-dev libbz2-dev zlib1g-dev
RUN apt-get -y install libsqlite3-dev libsqlite3-0 mariadb-client curl exif ftp
RUN docker-php-ext-install intl
RUN apt-get -y install --fix-missing zip unzip

# Composer
RUN curl -sS | php
RUN mv composer.phar /usr/local/bin/composer
RUN chmod +x /usr/local/bin/composer
RUN composer self-update

ADD conf/apache.conf /etc/apache2/sites-available/000-default.conf

RUN cd /var/www/html
RUN composer create-project codeigniter4/appstarter codeigniter4 -s rc
RUN ls
RUN chmod -R 0777 /var/www/html/codeigniter4/writable

RUN apt-get clean \
    && rm -r /var/lib/apt/lists/*
VOLUME /var/www/html

2) Go to the codeigniter folder
   cd codeigniter

3) build the image
docker build . -t codeginiter:4.0.0-rc.3

4) start the container
docker container run --publish 80:80 --name ci4 codeginiter:4.0.0-rc.3

At this point you should see the page on the browser ...

RE: Codeigniter 4 and Docker - MGatner - 01-02-2020

@atsanna This is great! Would you be willing to share this with a larger audience?

RE: Codeigniter 4 and Docker - atsanna - 01-02-2020

(01-02-2020, 09:03 AM)MGatner Wrote: @atsanna This is great! Would you be willing to share this with a larger audience?

@MGatner I have not invented anything: anyone who wishes can use it as he sees fit: it can be copied, modified, shared, published, sold, etc ... without any restrictions.

RE: Codeigniter 4 and Docker - atsanna - 04-13-2020

Hi, I received a message that pointed out that my Dockerfile was not properly mounting the folder on the host.

I have improved the docker file and want to share the changes with you.

You can find the update on github at this address

With this new version you should be able to mount the folder on the host.

I also published the repository on dockerhub
In this case you can start the container with the following command:
docker container run --publish 80:80 --name ci4 -v /localfolder:/var/www/html atsanna/codeigniter4:latest

RE: Codeigniter 4 and Docker - mal2tin - 04-14-2020

Thank you! I really appreciate your knowledge and want to share. In the docker image I am unable to connect to a mysql database. (I can with the same files and settings on the host) ...


Gracias! Aprecio mucho tu conocimiento y ganas de compartir. En la imagen de docker no logro conectarme a una base de datos mysql. (puedo con los mismos archivos y configuracion en el host)...


SYSTEMPATH/Database/MySQLi/Connection.php at line 110

103 {
104 $hostname = ($persistent === true) ? 'p:' . $this->hostname : $this->hostname;
105 $port = empty($this->port) ? null : $this->port;
106 $socket = null;
107 }
109 $client_flags = ($this->compress === true) ? MYSQLI_CLIENT_COMPRESS : 0;
110 $this->mysqli = mysqli_init();
114 $this->mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 10);
116 if (isset($this->strictOn))
117 {