title: In docker composer container raise error : Carbon 1 is deprecated
body: <p>I tried to run under docker my laravel 5.5 / postgres 9 app and in composer container I got error :</p>
  
  <blockquote>
    <p>Carbon 1 is deprecated, see how to migrate to Carbon 2.
    <a href="https://carbon.nesbot.com/docs/#api-carbon-2" rel="nofollow noreferrer">https://carbon.nesbot.com/docs/#api-carbon-2</a>
        You can run './vendor/bin/upgrade-carbon' to get help in updating carbon and other frameworks and libraries that depend on it.</p>
  </blockquote>
  
  <p>My composer.json:</p>
  
  <pre><code>{
      "name": "laravel/laravel",
      "description": "The Laravel Framework.",
      "keywords": ["framework", "laravel"],
      "license": "MIT",
      "type": "project",
      "require": {
          "php": "&gt;=5.6.4",
          "barryvdh/laravel-debugbar": "^2.3",
          "graham-campbell/markdown": "^8.0",
          "intervention/image": "^2.3",
          "khill/lavacharts": "3.0.*",
          "laravel/framework": "5.5.*",
          "laravel/socialite": "^3.0",
          "laravel/tinker": "~1.0",
          "laravelcollective/html": "^5.4.0",
          "nwidart/laravel-modules": "^2.2",
          "doctrine/dbal": "~2.5",
          "wboyz/laravel-enum": "^0.2.1"
      },
      "require-dev": {
          "fzaninotto/faker": "~1.4",
          "mockery/mockery": "0.9.*",
          "phpunit/phpunit": "~6.0",
          "stolz/laravel-html-tidy": "^0.1.1",
          "xethron/migrations-generator": "^2.0",
          "filp/whoops" : "~2.0" 
      },
      "autoload": {
          "classmap": [
              "database"
          ],
          "psr-4": {
              "App\\": "app/",
              "Modules\\": "Modules/"
          }
      },
      "autoload-dev": {
          "psr-4": {
              "Tests\\": "tests/"
          }
      },
      "scripts": {
          "post-root-package-install": [
              "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
          ],
          "post-create-project-cmd": [
              "php artisan key:generate"
          ],
          "post-install-cmd": [
              "Illuminate\\Foundation\\ComposerScripts::postInstall",
              "php artisan optimize"
          ],
          "post-update-cmd": [
              "Illuminate\\Foundation\\ComposerScripts::postUpdate",
              "php artisan optimize"
          ],
  
          "post-autoload-dump": [
              "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
              "@php artisan package:discover"
          ]
  
      },
      "config": {
          "preferred-install": "dist",
          "sort-packages": true,
          "optimize-autoloader": true
      }
  }
  </code></pre>
  
  <p>docker-compose.yml :</p>
  
  <pre><code>version: '3'
  
  services:
  
      web:
          build:
              context: ./web           # directory of web/Dockerfile.yml
              dockerfile: Dockerfile.yml
  
          environment:
              - APACHE_RUN_USER=#1000
  
          container_name: lprods_web
  
          volumes:
              - ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
          ports:
              - 8086:80
          working_dir: ${APP_PTH_CONTAINER}
  
  
  
      db:
          image: postgres:9.6.10-alpine
          container_name: lprods_db
          ports:
              - '5433:5432'
          restart: always
          environment: 
              POSTGRES_USER: 'postgres'
              POSTGRES_PASSWORD: '1'
              POSTGRES_DB: 'wprods'
          volumes:
              - ./init:/docker-entrypoint-initdb.d/
  
  
      adminer:
          image: adminer
          container_name: lprods_adminer
          restart: always
          ports:
              - 8087:80
          links:
              - db
  
      composer:
          image: composer:1.6
          container_name: lprods_composer
          volumes:
              - ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
          working_dir: ${APP_PTH_CONTAINER}
          command: composer install  --ignore-platform-reqs
  </code></pre>
  
  <p>and web/Dockerfile.yml :</p>
  
  <pre><code>  FROM php:7.1-apache
  
      RUN apt-get update &amp;&amp; \
      apt-get install -y \
      python \
      libfreetype6-dev \
      libwebp-dev \
      libjpeg62-turbo-dev \
      libpng-dev \
      libzip-dev \
      nano \
      git-core \
      curl \
      build-essential \
      openssl \
      libssl-dev \
      libgmp-dev \
      libldap2-dev \
      libpq-dev \
      netcat \
      sqlite3 \
      libsqlite3-dev \
      &amp;&amp; git clone https://github.com/nodejs/node.git \
      &amp;&amp; cd node \
      &amp;&amp; git checkout v12.0.0 \
      &amp;&amp; ./configure \
      &amp;&amp; make \
      &amp;&amp; make install
  
      RUN npm install cross-env
  
      RUN  docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/  --with-jpeg-dir=/usr/include/
  
  
      RUN  docker-php-ext-install gd pgsql pdo_pgsql zip gmp bcmath pcntl ldap sysvmsg exif \
      &amp;&amp; a2enmod rewrite
  
      COPY virtualhost.conf /etc/apache2/sites-enabled/000-default.conf
  </code></pre>
  
  <p>I am not sure which steps have I to take?
  To add command </p>
  
  <pre><code>RUN ./vendor/bin/upgrade-carbon
  </code></pre>
  
  <p>In the end of web/Dockerfile.yml file ? </p>
  
  <p><strong>MODIFIED :</strong>
  Entering the docker bash I tried to run proposed command, but got error :</p>
  
  <pre><code>$ docker-compose exec web bash
  root@863c9aa86d25:/var/www/lprods_docker_root# php -v
  PHP 7.1.33 (cli) (built: Oct 25 2019 06:33:10) ( NTS )
  Copyright (c) 1997-2018 The PHP Group
  Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
  root@863c9aa86d25:/var/www/lprods_docker_root# ./vendor/bin/upgrade-carbon
  sh: 1: composer: not found
  
  Fatal error: Uncaught Error: Class 'Composer\Composer' not found in /var/www/lprods_docker_root/vendor/nesbot/carbon/src/Carbon/Upgrade.php:131
  Stack trace:
  #0 /var/www/lprods_docker_root/vendor/nesbot/carbon/bin/upgrade-carbon(28): Carbon\Upgrade::upgrade()
  #1 {main}
    thrown in /var/www/lprods_docker_root/vendor/nesbot/carbon/src/Carbon/Upgrade.php on line 131
  </code></pre>
  
  <p>?</p>
  
  <p><strong>MODIFIED # 2:</strong> 
  I tried to add proposed upgrade-carbon command into web/Dockerfile.yml file :</p>
  
  <pre><code>RUN  docker-php-ext-install gd pgsql pdo_pgsql zip gmp bcmath pcntl ldap sysvmsg exif \
  &amp;&amp; a2enmod rewrite
  
  RUN ./vendor/bin/upgrade-carbon
  
  COPY virtualhost.conf /etc/apache2/sites-enabled/000-default.conf
  </code></pre>
  
  <p>But I got error : </p>
  
  <pre><code>Step 5/7 : RUN  docker-php-ext-install gd pgsql pdo_pgsql zip gmp bcmath pcntl ldap sysvmsg exif     &amp;&amp; a2enmod rewrite
   ---&gt; Using cache
   ---&gt; 60c29909c34a
  Step 6/7 : RUN ./vendor/bin/upgrade-carbon
   ---&gt; Running in 4fb9274ac5cb
  /bin/sh: 1: ./vendor/bin/upgrade-carbon: not found
  ERROR: Service 'web' failed to build: The command '/bin/sh -c ./vendor/bin/upgrade-carbon' returned a non-zero code: 127
  </code></pre>
  
  <p>I suppose I need to run upgrade-carbon command AFTER command in composer file:</p>
  
  <pre><code>command: composer install  --ignore-platform-reqs
  </code></pre>
  
  <p>Can I do this in docker and how?</p>
  
  <p>Thanks!</p>