# Docker Compose Set Timezone

- Link: https://sythsaz.ca/2025/11/zashtys/docker-compose-set-timezone/
- Published: 2025-11-04T09:48:26-07:00
- Author: sythsaz

I’m going to assume you have SSH and/or ftp access to modify the ‘compose.yaml’ 
file that you intend to modify.

All we need to do is add the ‘TZ’ variable to the environment section with your 
timezone name that you can get from [Wikipedia here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List),
like so.

  <!– wp:kevinbatdorf/code-block-pro {"code":"services:n service_name:n environment:
n – TZ=America/Edmonton","codeHTML":"

    ```github-light
    services:n  service_name:n    environment:n      - TZ=America/Edmonton
    ```

“,”language”:”yaml”,”theme”:”github-light”,”bgColor”:”#fff”,”textColor”:”#24292e”,”
fontSize”:”.875rem”,”fontFamily”:”Code-Pro-JetBrains-Mono”,”lineHeight”:”1.25rem”,”
clampFonts”:false,”lineNumbers”:true,”headerType”:”none”,”disablePadding”:false,”
footerType”:”simpleStringEnd”,”enableMaxHeight”:false,”seeMoreType”:””,”seeMoreString”:””,”
seeMoreAfterLine”:””,”seeMoreTransition”:false,”seeMoreCollapse”:false,”seeMoreCollapseString”:””,”
highestLineNumber”:4,”highlightingHover”:false,”lineHighlightColor”:”rgba(16, 41,
67, 0.2)”,”copyButton”:true,”copyButtonType”:”twoSquares”,”copyButtonUseTextarea”:
true,”useTabs”:false} –>

    ```github-light
    services:
      service_name:
        environment:
          - TZ=America/Edmonton
    ```

YAML

## Portainer

All you have to do for portainer is create a new environment variable called TZ 
with the value of your timezone, like so:

![](https://r2.sythsaz.ca/2025/11/portainer-timezone-set-2024x242.png)

Click Deploy just above the advanced section, then your container will be recreated
with the new environment variable!

## Compose More Detailed Version

Let’s edit the compose file:

  <!– wp:kevinbatdorf/code-block-pro {"code":"nano compose.yaml","codeHTML":"

    ```github-light
    nano compose.yaml
    ```

“,”language”:”bash”,”theme”:”github-light”,”bgColor”:”#fff”,”textColor”:”#24292e”,”
fontSize”:”.875rem”,”fontFamily”:”Code-Pro-JetBrains-Mono”,”lineHeight”:”1.25rem”,”
clampFonts”:false,”lineNumbers”:true,”headerType”:”none”,”disablePadding”:false,”
footerType”:”simpleStringEnd”,”enableMaxHeight”:false,”seeMoreType”:””,”seeMoreString”:””,”
seeMoreAfterLine”:””,”seeMoreTransition”:false,”seeMoreCollapse”:false,”seeMoreCollapseString”:””,”
highestLineNumber”:1,”highlightingHover”:false,”lineHighlightColor”:”rgba(16, 41,
67, 0.2)”,”copyButton”:true,”copyButtonType”:”twoSquares”,”copyButtonUseTextarea”:
true,”useTabs”:false} –>

    ```github-light
    nano compose.yaml
    ```

Bash

or…

  <!– wp:kevinbatdorf/code-block-pro {"code":"sudo nano compose.yaml","codeHTML":"

    ```github-light
    sudo nano compose.yaml
    ```

“,”language”:”bash”,”theme”:”github-light”,”bgColor”:”#fff”,”textColor”:”#24292e”,”
fontSize”:”.875rem”,”fontFamily”:”Code-Pro-JetBrains-Mono”,”lineHeight”:”1.25rem”,”
clampFonts”:false,”lineNumbers”:true,”headerType”:”none”,”disablePadding”:false,”
footerType”:”simpleStringEnd”,”enableMaxHeight”:false,”seeMoreType”:””,”seeMoreString”:””,”
seeMoreAfterLine”:””,”seeMoreTransition”:false,”seeMoreCollapse”:false,”seeMoreCollapseString”:””,”
highestLineNumber”:1,”highlightingHover”:false,”lineHighlightColor”:”rgba(16, 41,
67, 0.2)”,”copyButton”:true,”copyButtonType”:”twoSquares”,”copyButtonUseTextarea”:
true,”useTabs”:false} –>

    ```github-light
    sudo nano compose.yaml
    ```

Bash

Depending on what your permission for your file is.

Edit your compose file:

![sudo nano compose.yaml](https://r2.sythsaz.ca/2025/11/nano-compose-edit-1.png)

Go to the [Wikipedia page here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List)
and look up your Timezone in the table.

![Wikipedia Timezone Table - Timezone Identifier](https://r2.sythsaz.ca/2025/11/
wikipedia-timezone-page-location-2024x522.png)

![Nano Docker Compose edit file](https://r2.sythsaz.ca/2025/11/nano-edit-compose-
3.png)

Copy/Paste the ‘TZ Identifier’ and add it to your Docker Compose file like so. If
you don’t have the ‘environment’ section, you can copy and paste this.

<!– wp:kevinbatdorf/code-block-pro {"code":" environment:n – TZ=","codeHTML":"

    ```github-light
        environment:n      - TZ=
    ```

“,”language”:”yaml”,”theme”:”github-light”,”bgColor”:”#fff”,”textColor”:”#24292e”,”
fontSize”:”.875rem”,”fontFamily”:”Code-Pro-JetBrains-Mono”,”lineHeight”:”1.25rem”,”
clampFonts”:false,”lineNumbers”:true,”headerType”:”none”,”disablePadding”:false,”
footerType”:”simpleStringEnd”,”enableMaxHeight”:false,”seeMoreType”:””,”seeMoreString”:””,”
seeMoreAfterLine”:””,”seeMoreTransition”:false,”seeMoreCollapse”:false,”seeMoreCollapseString”:””,”
highestLineNumber”:2,”highlightingHover”:false,”lineHighlightColor”:”rgba(16, 41,
67, 0.2)”,”copyButton”:true,”copyButtonType”:”twoSquares”,”copyButtonUseTextarea”:
true,”useTabs”:false} –>

    ```github-light
        environment:
          - TZ=
    ```

YAML

Make sure you have 4 spaces from the start of the line and 2 spaces from the start
of the ‘environment’ section on the next line for the ‘- TZ=’ section(6 from the
beginning of the line). YAML is space-sensitive, so it will fail to compile if the
spaces are wrong.

You should validate the file to make sure you don’t get any errors. All you need
to do is type.

<!– wp:kevinbatdorf/code-block-pro {"code":"sudo docker compose -f compose.yaml 
config","codeHTML":"

    ```github-light
    sudo docker compose -f compose.yaml config
    ```

“,”language”:”bash”,”theme”:”github-light”,”bgColor”:”#fff”,”textColor”:”#24292e”,”
fontSize”:”.875rem”,”fontFamily”:”Code-Pro-JetBrains-Mono”,”lineHeight”:”1.25rem”,”
clampFonts”:false,”lineNumbers”:true,”headerType”:”none”,”disablePadding”:false,”
footerType”:”simpleStringEnd”,”enableMaxHeight”:false,”seeMoreType”:””,”seeMoreString”:””,”
seeMoreAfterLine”:””,”seeMoreTransition”:false,”seeMoreCollapse”:false,”seeMoreCollapseString”:””,”
highestLineNumber”:1,”highlightingHover”:false,”lineHighlightColor”:”rgba(16, 41,
67, 0.2)”,”copyButton”:true,”copyButtonType”:”twoSquares”,”copyButtonUseTextarea”:
true,”useTabs”:false} –>

    ```github-light
    sudo docker compose -f compose.yaml config
    ```

Bash

In this command, we use ‘sudo docker compose -f’, which, in this case, the ‘-f’ 
tells Docker Compose that we are dealing with Compose configuration files. ‘compose.
yaml’ is the name of the compose file in my case. Replace it with the name of your
file. Finally, ‘config’ is the command that tells it that we will parse, resolve
and render the compose file.

![](https://r2.sythsaz.ca/2025/11/validate-compose-file.png)

 You should get the output of the file if it validated correctly:

![Docker Compose validate config](https://r2.sythsaz.ca/2025/11/validate-compose-
file-final.png)

Now you can bring the container up with:

Replace the ‘compose.yaml’ with your file name.

  <!– wp:kevinbatdorf/code-block-pro {"code":"sudo docker compose -f compose.yaml
up -d","codeHTML":"

    ```github-light
    sudo docker compose -f compose.yaml up -d
    ```

“,”language”:”bash”,”theme”:”github-light”,”bgColor”:”#fff”,”textColor”:”#24292e”,”
fontSize”:”.875rem”,”fontFamily”:”Code-Pro-JetBrains-Mono”,”lineHeight”:”1.25rem”,”
clampFonts”:false,”lineNumbers”:true,”headerType”:”none”,”disablePadding”:false,”
footerType”:”simpleStringEnd”,”enableMaxHeight”:false,”seeMoreType”:””,”seeMoreString”:””,”
seeMoreAfterLine”:””,”seeMoreTransition”:false,”seeMoreCollapse”:false,”seeMoreCollapseString”:””,”
highestLineNumber”:1,”highlightingHover”:false,”lineHighlightColor”:”rgba(16, 41,
67, 0.2)”,”copyButton”:true,”copyButtonType”:”twoSquares”,”copyButtonUseTextarea”:
true,”useTabs”:false} –>

    ```github-light
    sudo docker compose -f compose.yaml up -d
    ```

Bash
