# How to modify Dockerfile?

**URL:** https://meta.discourse.org/t/how-to-modify-dockerfile/130531
**Category:** Self-hosting
**Tags:** docker
**Created:** [October 8, 2019, 11:26pm UTC](https://meta.discourse.org/t/how-to-modify-dockerfile/130531 "2019-10-08T23:26:05Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![slackmoehrle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slackmoehrle/32/82215_2.png) [@slackmoehrle](https://meta.discourse.org/u/slackmoehrle)
#### Post date: [October 8, 2019, 11:26pm UTC](https://meta.discourse.org/t/how-to-modify-dockerfile/130531/1 "2019-10-08T23:26:05Z")

</div>

I have a few other Docker containers and I run steps like this:

```sh
# Copy the current directory contents into the container at /app
COPY html /usr/share/nginx/html/
COPY dim.local.crt /etc/nginx/ssl/
COPY dim.local.key /etc/nginx/ssl/
COPY nginx.conf /etc/nginx/
COPY default.conf /etc/nginx/sites-enabled/

# Install any needed packages specified in requirements.txt
#RUN pip install -r requirements.txt

# need to restart nginx after COPY commands?
RUN 

RUN apt-get update && \
    apt-get install -y nano && \
    rm -fr /var/lib/apt/lists/*

```

I need to do some similar steps to my Discourse container, but where is the Dockerfile? I read that maybe I could add these to `containers/app.yml` at the end, but I’m not confident.

Can anyone explain?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 8, 2019, 11:41pm UTC](https://meta.discourse.org/t/how-to-modify-dockerfile/130531/2 "2019-10-08T23:41:30Z")

</div>

Can you explain exactly what you need?

There is no need to mess with docker file to add a custom certificate, we have a guide for that at [Allow SSL / HTTPS for your Discourse Docker setup](https://meta.discourse.org/t/advanced-setup-only-allowing-ssl-https-for-your-discourse-docker-setup/13847)

---

<div class="post-metadata">

### Author: ![slackmoehrle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slackmoehrle/32/82215_2.png) [@slackmoehrle](https://meta.discourse.org/u/slackmoehrle)
#### Post date: [October 8, 2019, 11:48pm UTC](https://meta.discourse.org/t/how-to-modify-dockerfile/130531/3 "2019-10-08T23:48:55Z")

</div>

I don’t want to do the exact same thing. I just have shell scripts and a crontab the I want to copy in to the container so I can automate some tasks.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 8, 2019, 11:52pm UTC](https://meta.discourse.org/t/how-to-modify-dockerfile/130531/4 "2019-10-08T23:52:42Z")

</div>

The last 5 lines of the app.yml contain an example of running custom commands, for example adding

```
- exec: curl example.com/script.sh | bash

```

Will download an execute that script.

---

<div class="post-metadata">

### Author: ![slackmoehrle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slackmoehrle/32/82215_2.png) [@slackmoehrle](https://meta.discourse.org/u/slackmoehrle)
#### Post date: [October 8, 2019, 11:56pm UTC](https://meta.discourse.org/t/how-to-modify-dockerfile/130531/5 "2019-10-08T23:56:19Z")

</div>

Yup, I see that, but each time I rebuild I get copy errors:

```sh
## Any custom commands to run after building
run:
  - exec: echo "Beginning of custom commands"
  ## If you want to set the 'From' email address for your first registration, uncomment and change:
  ## After getting the first signup email, re-comment the line. It only needs to run once.
  #- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
  
  - exec: cp /shared/rr/run_badges.sh /etc/cron.d/.
  - exec: cp /shared/rr/badges /etc/cron.d/.
  - exec: echo "End of custom commands"

```

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 8, 2019, 11:57pm UTC](https://meta.discourse.org/t/how-to-modify-dockerfile/130531/6 "2019-10-08T23:57:32Z")

</div>

Please share the error log too.

---

<div class="post-metadata">

### Author: ![slackmoehrle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slackmoehrle/32/82215_2.png) [@slackmoehrle](https://meta.discourse.org/u/slackmoehrle)
#### Post date: [October 8, 2019, 11:57pm UTC](https://meta.discourse.org/t/how-to-modify-dockerfile/130531/7 "2019-10-08T23:57:49Z")

</div>

I could indeed pull them from a url, that is a thought

The files are indeed present on the host:

```plaintext
# ls -al shared/rr/
badges run_badges.sh
#

```

Here is the error:

```plaintext
FAILED
--------------------
Pups::ExecError: cp /shared/rr/run_badges.sh /etc/cron.d/. failed with return #<Process::Status: pid 1457 exit 1>
Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'
exec failed with the params "cp /shared/rr/run_badges.sh /etc/cron.d/."
e23ff12630c8058c4b36ee8673404dafbe6791ec61aa630f1224400eba4e75e0
**FAILED TO BOOTSTRAP** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.

```

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 9, 2019, 3:47pm UTC](https://meta.discourse.org/t/how-to-modify-dockerfile/130531/8 "2019-10-09T15:47:59Z")

</div>

The `/shared` dir inside the container is mapped, by default, to `/var/discourse/shared/standalone` so you are missing a directory in there.

---

<div class="post-metadata">

### Author: ![slackmoehrle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slackmoehrle/32/82215_2.png) [@slackmoehrle](https://meta.discourse.org/u/slackmoehrle)
#### Post date: [October 9, 2019, 4:50pm UTC](https://meta.discourse.org/t/how-to-modify-dockerfile/130531/9 "2019-10-09T16:50:16Z")

</div>

What mistake am I making @Falco

command:

```plaintext
- exec: cp /shared/standalone/sql/run_badges.sh /root

```

```sh
Pups::ExecError: cp /shared/standalone/sql/run_badges.sh /root failed with return #<Process::Status: pid 1728 exit 1>

```

---

<div class="post-metadata">

### Author: ![slackmoehrle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/slackmoehrle/32/82215_2.png) [@slackmoehrle](https://meta.discourse.org/u/slackmoehrle)
#### Post date: [October 9, 2019, 10:01pm UTC](https://meta.discourse.org/t/how-to-modify-dockerfile/130531/10 "2019-10-09T22:01:21Z")

</div>

> [@Falco](#):
>
> - exec: curl [example.com/script.sh](http://example.com/script.sh) | bash

actually, this solution works pretty nicely. Thanks for mentioning it.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [June 12, 2023, 5:51am UTC](https://meta.discourse.org/t/how-to-modify-dockerfile/130531/11 "2023-06-12T05:51:58Z")

</div>



---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [June 12, 2023, 5:57am UTC](https://meta.discourse.org/t/how-to-modify-dockerfile/130531/12 "2023-06-12T05:57:48Z")

</div>


