Unable to run a Confluence docker container from a custom image built on Windows
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Docker allows building your own custom image from the official Confluence image available at Docker Hub.
However, by following the exact same steps described in the Advanced Configuration section to build the new image on Windows (without customizing any file), you may run into an error when trying to run the container using that image.
Environment
- Git for Windows (used to clone the official repository)
- Docker (to build the new image)
- Windows OS
Diagnosis
When trying to run a new container using the newly built image will give you the following error message:
$ docker run -p 8090:8090 --name="newContainer" -v confluence:/var/atlassian/application-data/confluence newImage Unknown option: - usage: /usr/bin/python3 [option] ... [-c cmd | -m mod | file | -] [arg] ... Try `python -h' for more information.
When inspecting the container logs, will give you the same error message
$ docker logs newContainer Unknown option: - usage: /usr/bin/python3 [option] ... [-c cmd | -m mod | file | -] [arg] ... Try `python -h' for more information.
Using a hexdump on the entrypoint.py checked out from the repository on Windows will present several 0d 0a byte sequences:
$ hexdump entrypoint.py 0000000 23 21 2f 75 73 72 2f 62 69 6e 2f 70 79 74 68 6f 0000010 6e 33 20 2d 42 0d 0a 0d 0a 66 72 6f 6d 20 65 6e 0000020 74 72 79 70 6f 69 6e 74 5f 68 65 6c 70 65 72 73 0000030 20 69 6d 70 6f 72 74 20 65 6e 76 2c 20 67 65 6e 0000040 5f 63 66 67 2c 20 73 74 72 32 62 6f 6f 6c 2c 20 0000050 73 74 61 72 74 5f 61 70 70 0d 0a 0d 0a 0d 0a 52 0000060 55 4e 5f 55 53 45 52 20 3d 20 65 6e 76 5b 27 72 0000070 75 6e 5f 75 73 65 72 27 5d 0d 0a 52 55 4e 5f 47 0000080 52 4f 55 50 20 3d 20 65 6e 76 5b 27 72 75 6e 5f 0000090 67 72 6f 75 70 27 5d 0d 0a 43 4f 4e 46 4c 55 45 00000a0 4e 43 45 5f 49 4e 53 54 41 4c 4c 5f 44 49 52 20 00000b0 3d 20 65 6e 76 5b 27 63 6f 6e 66 6c 75 65 6e 63 00000c0 65 5f 69 6e 73 74 61 6c 6c 5f 64 69 72 27 5d 0d 00000d0 0a 43 4f 4e 46 4c 55 45 4e 43 45 5f 48 4f 4d 45 00000e0 20 3d 20 65 6e 76 5b 27 63 6f 6e 66 6c 75 65 6e 00000f0 63 65 5f 68 6f 6d 65 27 5d 0d 0a 0d 0a 67 65 6e 0000100 5f 63 66 67 28 27 73 65 72 76 65 72 2e 78 6d 6c 0000110 2e 6a 32 27 2c 20 66 27 7b 43 4f 4e 46 4c 55 45 0000120 4e 43 45 5f 49 4e 53 54 41 4c 4c 5f 44 49 52 7d 0000130 2f 63 6f 6e 66 2f 73 65 72 76 65 72 2e 78 6d 6c 0000140 27 29 0d 0a 67 65 6e 5f 63 66 67 28 27 73 65 72 0000150 61 70 68 2d 63 6f 6e 66 69 67 2e 78 6d 6c 2e 6a 0000160 32 27 2c 0d 0a 20 20 20 20 20 20 20 20 66 27 7b 0000170 43 4f 4e 46 4c 55 45 4e 43 45 5f 49 4e 53 54 41 0000180 4c 4c 5f 44 49 52 7d 2f 63 6f 6e 66 6c 75 65 6e 0000190 63 65 2f 57 45 42 2d 49 4e 46 2f 63 6c 61 73 73 00001a0 65 73 2f 73 65 72 61 70 68 2d 63 6f 6e 66 69 67 00001b0 2e 78 6d 6c 27 29 0d 0a 67 65 6e 5f 63 66 67 28 00001c0 27 63 6f 6e 66 6c 75 65 6e 63 65 2d 69 6e 69 74 00001d0 2e 70 72 6f 70 65 72 74 69 65 73 2e 6a 32 27 2c 00001e0 0d 0a 20 20 20 20 20 20 20 20 66 27 7b 43 4f 4e 00001f0 46 4c 55 45 4e 43 45 5f 49 4e 53 54 41 4c 4c 5f 0000200 44 49 52 7d 2f 63 6f 6e 66 6c 75 65 6e 63 65 2f 0000210 57 45 42 2d 49 4e 46 2f 63 6c 61 73 73 65 73 2f 0000220 63 6f 6e 66 6c 75 65 6e 63 65 2d 69 6e 69 74 2e 0000230 70 72 6f 70 65 72 74 69 65 73 27 29 0d 0a 67 65 0000240 6e 5f 63 66 67 28 27 63 6f 6e 66 6c 75 65 6e 63 0000250 65 2e 63 66 67 2e 78 6d 6c 2e 6a 32 27 2c 20 66 0000260 27 7b 43 4f 4e 46 4c 55 45 4e 43 45 5f 48 4f 4d 0000270 45 7d 2f 63 6f 6e 66 6c 75 65 6e 63 65 2e 63 66 0000280 67 2e 78 6d 6c 27 2c 0d 0a 20 20 20 20 20 20 20 0000290 20 75 73 65 72 3d 52 55 4e 5f 55 53 45 52 2c 20 00002a0 67 72 6f 75 70 3d 52 55 4e 5f 47 52 4f 55 50 2c 00002b0 20 6f 76 65 72 77 72 69 74 65 3d 46 61 6c 73 65 00002c0 29 0d 0a 0d 0a 73 74 61 72 74 5f 61 70 70 28 66 00002d0 27 7b 43 4f 4e 46 4c 55 45 4e 43 45 5f 49 4e 53 00002e0 54 41 4c 4c 5f 44 49 52 7d 2f 62 69 6e 2f 73 74 00002f0 61 72 74 2d 63 6f 6e 66 6c 75 65 6e 63 65 2e 73 0000300 68 20 2d 66 67 27 2c 20 43 4f 4e 46 4c 55 45 4e 0000310 43 45 5f 48 4f 4d 45 2c 20 6e 61 6d 65 3d 27 43 0000320 6f 6e 66 6c 75 65 6e 63 65 27 29 0d 0a 000032d
Cause
Git for Windows is configured to Checkout Windows-style.
There's a slight difference on how Windows and Unix systems handle line-endings on text files. Unix uses the line-feed character (/n, 0x0a) while Windows will insert an additional carriage-return character (/r/n, 0x0d 0x0a).
Solution
Follow the official Git Documentation to set the core.autocrlf as false, in Windows:
git config --global core.autocrlf false
This will prevent Windows from automatically adding the carriage-return character at the end of text files.
- Clone the official Docker image repository again
- Re-build the image