title: Codeigniter 3 Docker Compose Setup
body: <p>I am currently working with WAMP on my computer, but I would like to move over to docker in order to make the Codeigniter application's setup easier. I am using CodeIgniter 3 which I have setup to use the HMVC model. On the docker setup, I can get to the index page of the whole application from the browser, but I get several errors from the internal system files of Codeigniter. </p>
  
  <p>Here are the errors I am getting:</p>
  
  <pre><code>A PHP Error was encountered
  Severity: Warning
  
  Message: mkdir(): Invalid path
  
  Filename: drivers/Session_files_driver.php
  
  Line Number: 136
  
  Backtrace:
  
  File: /var/www/html/application/third_party/MX/Loader.php
  Line: 173
  Function: _ci_load_library
  
  File: /var/www/html/application/third_party/MX/Loader.php
  Line: 192
  Function: library
  
  File: /var/www/html/application/third_party/MX/Loader.php
  Line: 153
  Function: libraries
  
  File: /var/www/html/application/third_party/MX/Loader.php
  Line: 65
  Function: initialize
  
  File: /var/www/html/application/third_party/MX/Base.php
  Line: 55
  Function: __construct
  
  File: /var/www/html/application/third_party/MX/Base.php
  Line: 60
  Function: __construct
  
  File: /var/www/html/application/third_party/MX/Controller.php
  Line: 6
  Function: require
  
  File: /var/www/html/application/third_party/MX/Modules.php
  Line: 123
  Function: include_once
  
  File: /var/www/html/application/modules/user/controllers/User.php
  Line: 5
  Function: spl_autoload_call
  
  File: /var/www/html/index.php
  Line: 315
  Function: require_once
  
  
  Warning: Uncaught Exception: Session: Configured save path '' is not a directory, doesn't exist or cannot be created. in /var/www/html/system/libraries/Session/drivers/Session_files_driver.php:138 Stack trace: #0 [internal function]: CI_Session_files_driver-&gt;open('', 'ci_session') #1 /var/www/html/system/libraries/Session/Session.php(143): session_start() #2 /var/www/html/system/core/Loader.php(1281): CI_Session-&gt;__construct() #3 /var/www/html/system/core/Loader.php(1174): CI_Loader-&gt;_ci_init_library('Session', 'CI_', NULL, 'session') #4 /var/www/html/system/core/Loader.php(1037): CI_Loader-&gt;_ci_load_stock_library('Session', 'Session/', NULL, NULL) #5 /var/www/html/system/core/Loader.php(1082): CI_Loader-&gt;_ci_load_library('Session', NULL, NULL) #6 /var/www/html/application/third_party/MX/Loader.php(173): CI_Loader-&gt;_ci_load_library('Session', NULL, NULL) #7 /var/www/html/application/third_party/MX/Loader.php(192): MX_Loader-&gt;library('session') #8 /var/www/html/application/third_party/MX/Loader.php(153): MX_Loader-&gt;lib in /var/www/html/system/libraries/Session/drivers/Session_files_driver.php on line 138
  
  Fatal error: session_start(): Failed to initialize storage module: user (path: ) in /var/www/html/system/libraries/Session/Session.php on line 143
  A PHP Error was encountered
  Severity: Warning
  
  Message: Cannot modify header information - headers already sent by (output started at /var/www/html/system/core/Exceptions.php:271)
  
  Filename: core/Common.php
  
  Line Number: 570
  
  Backtrace:
  
  A PHP Error was encountered
  Severity: Error
  
  Message: session_start(): Failed to initialize storage module: user (path: )
  
  Filename: Session/Session.php
  
  Line Number: 143
  
  Backtrace:
  </code></pre>
  
  <p>Here are my config variables for the session:</p>
  
  <pre><code>$config['sess_driver'] = 'files';
  $config['sess_cookie_name'] = 'ci_session';
  $config['sess_expiration'] = 7200;
  $config['sess_save_path'] = NULL;
  $config['sess_match_ip'] = FALSE;
  $config['sess_time_to_update'] = 300;
  $config['sess_regenerate_destroy'] = FALSE;
  </code></pre>
  
  <p>I would prefer to not to have to save any session information to a file if that is possible. When working in WAMP this configuration worked just fine.</p>
  
  <p>Here is my docker compose file:</p>
  
  <pre><code>version: '3'
  services:
    apache:
      image: php:7.0-apache
      hostname: apache
      ports:
      - "80:80" # normal php port for trafic and functionality
      volumes:
        - ./app:/var/www/html
  
    mysql:
      image: mysql:8.0
      hostname: mysql
      ports:
        - "3306:3306" # mysql connection port
      environment:
        MYSQL_USER_FILE: var/lib/mysql-user
        MYSQL_PASSWORD_FILE: var/lib/mysql-user-p
        MYSQL_DATABASE_FILE: var/lib/mysql-db
        MYSQL_ROOT_PASSWORD_FILE: var/lib/mysql-root-p
      volumes:
        - ./data:/var/lib/
  
    phpmyadmin:
      image: phpmyadmin/phpmyadmin:latest
      restart: always
      links:
        - mysql
      ports:
        - "8183:80" # phpmyadmin login page
      environment:
        PMA_USER: user
        PMA_PASSWORD: password
        PMA_ARBITRARY: 1
  </code></pre>
  
  <p>-app: contains codeigniter files</p>
  
  <p>-data: contains a folder for the placement of mysql data and a few config files.</p>
  
  <p>Thank you for the help!</p>