Modules installed with docker-php-ext-install are not enabled
Project ID: 6ddc3509-9905-4080-9429-3330b1908098
Dockerfile:
FROM php:8.2-apache
RUN apt-get update && apt-get install -y \
libpng-dev \
libzip-dev \
zip \
libpq-dev \
git \
&& docker-php-ext-install pdo pdo_pgsql gd zip
RUN a2enmod rewrite
WORKDIR /var/www/html
COPY . .
RUN sed -i 's!/var/www/html!/var/www/html/public!g' /etc/apache2/sites-available/000-default.conf
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
RUN composer install --prefer-dist --no-scripts --no-dev --no-interaction
EXPOSE 80
I've been trying to install and enable a couple of PHP modules via docker-php-ext-install. It works well if I run the build in my local Docker environment using:
docker compose up -d --build
But if I run the deployment on Railway using:
railway up
Everything seems to be completing successfully, but the modules installed with docker-php-ext-install are not loaded.
My local Docker container:
root@0c3851d06742:/var/www/html/bin# php -m
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
gd
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_pgsql
pdo_sqlite
Phar
posix
random
readline
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zip
zlib
[Zend Modules]
notice the loaded pdo_pgsql, pdo_sqlite, gd and zip modules.
Railway deployment:
sl@SL-DELL:/www/symfony-book-management$ railway run php -m
[PHP Modules]
calendar
Core
ctype
date
dom
exif
FFI
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
openssl
pcntl
pcre
PDO
Phar
posix
random
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zlib
[Zend Modules]
Zend OPcache
pdo_pgsql, pdo_sqlite, gd and zip modules are missing.
Could you please help? Thanks!
Solution:Jump to solution
railway does not provide any way to ssh into the container or run commands on it
6 Replies
Project ID:
6ddc3509-9905-4080-9429-3330b1908098
I'd like to note that
railway run
does not SSH into the railway deployment, all commands ran through it will only ever run locally on your own computer@Brody thanks for pointing that out! so is there a way to ssh into the running container? or how do I run a command post-deployment?
Solution
railway does not provide any way to ssh into the container or run commands on it
if modules are missing on railway it is because you have not installed them correctly with your dockerfile
the modules do work in my local Docker environment. I think the main issue was misunderstanding how railway run command works. I was trying to load fixtures into my database post-deployment.
thanks for your help!