# Laravel Fly Docker Image

**URL:** <https://community.fly.io/t/laravel-fly-docker-image/11165>\
**Category:** Laravel\
**Created:** [March 2, 2023, 8:40am UTC](https://community.fly.io/t/laravel-fly-docker-image/11165 "2023-03-02T08:40:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![discoverlance](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/discoverlance/32/36126_2.png) [@discoverlance](https://community.fly.io/u/discoverlance)\
**Post date:** [March 2, 2023, 8:40am UTC](https://community.fly.io/t/laravel-fly-docker-image/11165/1 "2023-03-02T08:40:12Z")

</div>

Hi,  
When creating a new laravel application with fly, the Dockerfile created uses an image from `fideloper/fly-laravel:${PHP_VERSION} as base`.

This works alright but I need my image to contain the `postgres-client` or `pg_dump` package for me to use _spatie laravel backups_ to backup my database.

Apparently, I am not able to sudo apt install new packages once using the `fideloper/fly-laravel:8.2` package. I checked out the image on docker hub [https://hub.docker.com/r/fideloper/fly-laravel/tags](https://hub.docker.com/r/fideloper/fly-laravel/tags) but it looks like it’s not linked to any github account for me to see and perhaps customize the Dockerfile.

In this case, I want to customize the Dockerfile, are there any suggestions or ways I can do that to enable `pg_dump`?

---

<div class="post-metadata">

**Author:** ![AsymetricalData](https://avatars.discourse-cdn.com/v4/letter/a/58956e/32.png) [@AsymetricalData](https://community.fly.io/u/AsymetricalData)\
**Post date:** [March 2, 2023, 10:24am UTC](https://community.fly.io/t/laravel-fly-docker-image/11165/2 "2023-03-02T10:24:01Z")

</div>

That’s weird because I can install custom package with the same image.

Here I have my Mongodb install in my Dockerfile

```auto
RUN apt-get update && apt-get install -y \
  php${PHP_VERSION}-mongodb \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists/*

```

---

<div class="post-metadata">

**Author:** ![discoverlance](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/discoverlance/32/36126_2.png) [@discoverlance](https://community.fly.io/u/discoverlance)\
**Post date:** [March 2, 2023, 3:14pm UTC](https://community.fly.io/t/laravel-fly-docker-image/11165/3 "2023-03-02T15:14:05Z")

</div>

Thanks for this suggestion. @AsymetricalData I realized I was using sudo and that was one of the factors causing the commands to fail.

In the end, I was also missing the postgres linux source. I was also getting errors, `Unable to find package information`.

So I ended up using this to add the client:

```auto
RUN curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/pgdg.gpg >/dev/null

RUN echo "deb [signed-by=/usr/share/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt focal-pgdg main" > /etc/apt/sources.list.d/pgdg.list

RUN apt-get update

RUN apt-get install -y postgresql-client-13

```

PS: I got the above command from laravel sail 8.2 Dockerfile. The change I had to make was to use `focal-pgdg` instead of `jammy-pgdg` for the postgres deb repo source as the laravel base image uses ubuntu 22.04.

---

<div class="post-metadata">

**Author:** ![fideloper-fly](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/fideloper-fly/32/3834_2.png) [@fideloper-fly](https://community.fly.io/u/fideloper-fly)\
**Post date:** [March 10, 2023, 1:23pm UTC](https://community.fly.io/t/laravel-fly-docker-image/11165/4 "2023-03-10T13:23:49Z")

</div>

Hey there!

Sorry for the trouble on this - If you want to take a peak, the repository generating those Docker images is found here: [GitHub - fly-apps/laravel-docker: Base Docker images for use with Laravel on Fly.io](https://github.com/fly-apps/laravel-docker)

I’ll add that to the readme.

---

<div class="post-metadata">

**Author:** ![discoverlance](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/discoverlance/32/36126_2.png) [@discoverlance](https://community.fly.io/u/discoverlance)\
**Post date:** [March 10, 2023, 4:56pm UTC](https://community.fly.io/t/laravel-fly-docker-image/11165/5 "2023-03-10T16:56:12Z")

</div>

> [@fideloper-fly](#):
>
> GitHub - fly-apps/laravel-docker: Base Docker images for use with Laravel on [Fly.io](http://Fly.io)

Oh good, thanks very much. I wanted to take a peak at it earlier but could not find the Dockerfile

---

<div class="post-metadata">

**Author:** ![fideloper-fly](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/fideloper-fly/32/3834_2.png) [@fideloper-fly](https://community.fly.io/u/fideloper-fly)\
**Post date:** [March 14, 2023, 1:20pm UTC](https://community.fly.io/t/laravel-fly-docker-image/11165/6 "2023-03-14T13:20:20Z")

</div>

Just a quick note: I’ve setup the git repository to rebuild the images every 3 days so the latest minor (point releases) of PHP get updated in the base images:

> **[GitHub - fly-apps/laravel-docker: Base Docker images for use with Laravel on...](https://github.com/fly-apps/laravel-docker)**
>
> Base Docker images for use with Laravel on Fly.io. Contribute to fly-apps/laravel-docker development by creating an account on GitHub.
