# How to use php-cli from within n8n docker container?

**URL:** <https://community.n8n.io/t/how-to-use-php-cli-from-within-n8n-docker-container/7632>\
**Category:** Questions\
**Created:** [September 2, 2021, 2:31pm UTC](https://community.n8n.io/t/how-to-use-php-cli-from-within-n8n-docker-container/7632 "2021-09-02T14:31:58Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris7935](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Chris7935](https://community.n8n.io/u/Chris7935)\
**Post date:** [September 2, 2021, 2:31pm UTC](https://community.n8n.io/t/how-to-use-php-cli-from-within-n8n-docker-container/7632/1 "2021-09-02T14:31:58Z")

</div>

Hello,

I’ve seen this one:

> [@Ssh command not available from Execute\_Command node](http://community.n8n.io/t/ssh-command-not-available-from-execute-command-node/739):
>
> Hi, I’m trying to execute something like this, in a docker n8n server: ssh user@linux\_server remote\_command to get statistics and info from remote servers and process that on a n8n workflow, but I can’t find ssh present from the n8n server’s shell (root:/bin/sh), neither dpkg or apt application to install ubuntu’s openssh package. Is there a better alternative to remote command execution, or a way to install openssh utilities?

> <https://stackoverflow.com/questions/35689976/how-to-install-openssh-on-alpine>

and tried:

```auto
docker run -it n8nio/n8n /bin/ash
/data $ apk update && apk upgrade
ERROR: Unable to lock database: Permission denied
ERROR: Failed to open apk database: Permission denied

```

How would I install php in my n8n docker?  
Is it wise to do so in the first place, or would it be better to add an image like ‘traefik’ via the docker-composer? (and if so - how? I’m fairly new to the docker).

---

<div class="post-metadata">

**Author:** ![harshil1712](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/harshil1712/32/1374_2.png) [@harshil1712](https://community.n8n.io/u/harshil1712)\
**Post date:** [September 2, 2021, 2:58pm UTC](https://community.n8n.io/t/how-to-use-php-cli-from-within-n8n-docker-container/7632/2 "2021-09-02T14:58:07Z")

</div>

Hey @Chris7935,

Do you want to use access the php-cli via SSHing to your server? Or do you want to access the php-cli on the same server, without SSH?

---

<div class="post-metadata">

**Author:** ![Chris7935](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Chris7935](https://community.n8n.io/u/Chris7935)\
**Post date:** [September 2, 2021, 3:09pm UTC](https://community.n8n.io/t/how-to-use-php-cli-from-within-n8n-docker-container/7632/3 "2021-09-02T15:09:51Z")

</div>

Just by the execute command node. (So ideally without SSH)

---

<div class="post-metadata">

**Author:** ![harshil1712](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/harshil1712/32/1374_2.png) [@harshil1712](https://community.n8n.io/u/harshil1712)\
**Post date:** [September 2, 2021, 3:17pm UTC](https://community.n8n.io/t/how-to-use-php-cli-from-within-n8n-docker-container/7632/4 "2021-09-02T15:17:32Z")

</div>

This post can be helpful: [Running Python with n8n - #2 by dali](http://community.n8n.io/t/running-python-with-n8n/5715/2)

---

<div class="post-metadata">

**Author:** ![Chris7935](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Chris7935](https://community.n8n.io/u/Chris7935)\
**Post date:** [September 2, 2021, 3:26pm UTC](https://community.n8n.io/t/how-to-use-php-cli-from-within-n8n-docker-container/7632/5 "2021-09-02T15:26:52Z")

</div>

That does help somewhat.  
What I don’t seem to be understanding yet is:  
I’ve got all my workflows etc. already build. Now I’d just like to add php - but keep everything as it is.  
Will I be overriding anything with the instructions in [Running Python with n8n - #6 by chris](http://community.n8n.io/t/running-python-with-n8n/5715/6) ?  
(it sounds more like taking a new image?)

---

<div class="post-metadata">

**Author:** ![harshil1712](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/harshil1712/32/1374_2.png) [@harshil1712](https://community.n8n.io/u/harshil1712)\
**Post date:** [September 3, 2021, 7:04am UTC](https://community.n8n.io/t/how-to-use-php-cli-from-within-n8n-docker-container/7632/6 "2021-09-03T07:04:02Z")

</div>

Are you using a docker-compose file to start the n8n docker container?

In any case, I would suggest that you make sure you have persistent data storage. I suggest you read on storage here: [Manage data in Docker | Docker Documentation](https://docs.docker.com/storage/)

---

<div class="post-metadata">

**Author:** ![Chris7935](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Chris7935](https://community.n8n.io/u/Chris7935)\
**Post date:** [September 3, 2021, 7:42am UTC](https://community.n8n.io/t/how-to-use-php-cli-from-within-n8n-docker-container/7632/7 "2021-09-03T07:42:21Z")

</div>

Yes, docker-compose.  
And I’ve “mounted” a folder on my host file system which persists after I switched of docker - that’s working well.  
I’m more worried about the workflows that I’ve built - they are stored inside a SQLite, if I understood that correctly? I didn’t want to move to MySQL or PostgreSQL for my first server with n8n (mostly a MVP at the moment).

The link that you’ve shared ([Running Python with n8n - #2 by dali](http://community.n8n.io/t/running-python-with-n8n/5715/2)) sounds like I’d be adding sth. to a docker file and I’d be re-creating my n8n ‘instance’ from the docker file + PHP. I assumed, I’d loose my workflows which are currently in SQLite?

---

<div class="post-metadata">

**Author:** ![harshil1712](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/harshil1712/32/1374_2.png) [@harshil1712](https://community.n8n.io/u/harshil1712)\
**Post date:** [September 3, 2021, 10:22am UTC](https://community.n8n.io/t/how-to-use-php-cli-from-within-n8n-docker-container/7632/8 "2021-09-03T10:22:14Z")

</div>

I am not 100% certain, but if you add it your docker-compose file, and restart it, you should be fine. You shouldn’t loose any data.

---

<div class="post-metadata">

**Author:** ![harshil1712](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/harshil1712/32/1374_2.png) [@harshil1712](https://community.n8n.io/u/harshil1712)\
**Post date:** [September 9, 2021, 2:45pm UTC](https://community.n8n.io/t/how-to-use-php-cli-from-within-n8n-docker-container/7632/9 "2021-09-09T14:45:12Z")

</div>

Hey @Chris7935,

Just wanted to check-in and see if you still need help 🙂

---

<div class="post-metadata">

**Author:** ![Chris7935](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Chris7935](https://community.n8n.io/u/Chris7935)\
**Post date:** [September 10, 2021, 3:46am UTC](https://community.n8n.io/t/how-to-use-php-cli-from-within-n8n-docker-container/7632/10 "2021-09-10T03:46:31Z")

</div>

It’s working now, but I’m sure it’s a quick an dirty solution:

```auto
docker-compose up -d 

docker container ls 
docker exec -it a481d64b5481 /bin/ash
# whoami
root

apk add php7 php7-cli php7-gd php7-ftp
php -v
exit

```

Do you have some examples of how to add this to my docker compose file?

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [September 10, 2021, 5:00am UTC](https://community.n8n.io/t/how-to-use-php-cli-from-within-n8n-docker-container/7632/11 "2021-09-10T05:00:19Z")

</div>

Not sure about within the compose file but you could just make your own dockerfile and pull the n8n image and install your extras then use that as your image for compose.

That link above has a comment from Jan on it showing how you can do it.
