Skip to content

Commit 147b668

Browse files
maxvpharshil1712
authored andcommitted
[ZT] Add cert to Docker (#17783)
1 parent 11c47ec commit 147b668

File tree

1 file changed

+137
-0
lines changed
  • src/content/docs/cloudflare-one/connections/connect-devices/warp/user-side-certificates

1 file changed

+137
-0
lines changed

src/content/docs/cloudflare-one/connections/connect-devices/warp/user-side-certificates/manual-deployment.mdx

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,143 @@ On some systems you may need to set the following in your path/export list:
489489
export NODE_EXTRA_CA_CERTS='[PATH_TO_CLOUDFLARE_CERT.pem]'
490490
```
491491

492+
### Docker
493+
494+
To install a certificate for use in a Docker container:
495+
496+
1. [Download a Cloudflare certificate](#download-the-cloudflare-root-certificate) in `.pem` format.
497+
2. Create a directory for certificates in your Docker project:
498+
499+
```sh
500+
cd docker-project
501+
mkdir certs
502+
mv /path/to/downloaded/certificate.pem certs/
503+
```
504+
505+
3. Verify the certificate was moved to the directory correctly. Your project should have the following structure:
506+
507+
```sh
508+
docker-project/
509+
├── Dockerfile
510+
└── certs/
511+
└── certificate.pem
512+
```
513+
514+
4. Add the certificate to your Docker image:
515+
516+
<Tabs> <TabItem label="During build process">
517+
518+
To add the certificate to your Dockerfile to install it during the build process:
519+
520+
1. Add the certificate install directions to your Dockerfile. For example:
521+
522+
```docker title="Red Hat-based images"
523+
FROM registry.access.redhat.com/ubi9/ubi:latest
524+
# Or FROM centos:7 or FROM fedora:38
525+
526+
# Install necessary certificates package
527+
RUN dnf install -y ca-certificates
528+
529+
# Copy and add Cloudflare root certificate
530+
COPY certs/certificate.pem /etc/pki/ca-trust/source/anchors/certificate.crt
531+
RUN update-ca-trust extract
532+
```
533+
534+
```docker title="Debian-based images"
535+
FROM debian:12
536+
# Or FROM ubuntu:22.04
537+
538+
# Install necessary certificates package
539+
RUN apt-get update && apt-get install -y ca-certificates
540+
541+
# Copy and add Cloudflare root certificate
542+
COPY certs/certificate.pem /usr/local/share/ca-certificates/certificate.crt
543+
RUN update-ca-certificates
544+
```
545+
546+
```docker title="Alpine-based images"
547+
FROM alpine:3.18
548+
549+
# Install necessary certificates package
550+
RUN apk add --no-cache ca-certificates
551+
552+
# Copy and add Cloudflare root certificate
553+
COPY certs/certificate.pem /usr/local/share/ca-certificates/certificate.crt
554+
RUN update-ca-certificates
555+
```
556+
557+
2. Build the Docker image:
558+
559+
```sh
560+
docker build -t <your-container-name> .
561+
```
562+
563+
3. Verify the certificate was installed:
564+
565+
```sh title="Red Hat-based images"
566+
docker run --rm your-image-name sh -c "cat /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem | grep Cloudflare"
567+
```
568+
569+
```sh title="Debian and Alpine-based images"
570+
docker run --rm your-image-name sh -c "cat /etc/ssl/certs/certificate.pem"
571+
```
572+
573+
</TabItem>
574+
575+
<TabItem label="During runtime">
576+
577+
To add the certificate to your Docker Compose file to install it during runtime:
578+
579+
1. Add the certificate install directions to your `docker-compose.yml` file. For example:
580+
581+
```yaml title="Red Hat-based containers"
582+
version: '3'
583+
services:
584+
redhat-app:
585+
image: registry.access.redhat.com/ubi9/ubi:latest
586+
volumes:
587+
- certs/certificate.pem:/etc/pki/ca-trust/source/anchors/certificate.pem
588+
entrypoint: /bin/sh -c "dnf install -y ca-certificates && update-ca-trust extract && app start"
589+
```
590+
591+
```yaml title="Debian-based containers"
592+
version: '3'
593+
services:
594+
debian-app:
595+
image: debian:12
596+
volumes:
597+
- certs/certificate.pem:/usr/local/share/ca-certificates/certificate.crt
598+
entrypoint: /bin/sh -c "apt-get update && apt-get install -y ca-certificates && update-ca-certificates && app start"
599+
```
600+
601+
```yaml title="Alpine-based containers"
602+
version: '3'
603+
services:
604+
alpine-app:
605+
image: alpine:3.18
606+
volumes:
607+
- certs/certificate.pem:/usr/local/share/ca-certificates/certificate.pem
608+
entrypoint: /bin/sh -c "apk add --no-cache ca-certificates && update-ca-certificates && app start"
609+
```
610+
611+
2. Run the container:
612+
613+
```sh
614+
docker-compose up
615+
```
616+
617+
3. Verify the certificate was installed:
618+
619+
```sh title="Red Hat-based containers"
620+
docker exec -it <container-name> sh -c "cat /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem | grep Cloudflare"
621+
```
622+
623+
```sh title="Debian and Alpine-based containers"
624+
docker exec -it <container-name> sh -c "cat /etc/ssl/certs/ca-certificates.crt | grep Cloudflare"
625+
```
626+
627+
</TabItem> </Tabs>
628+
492629
### Google Cloud
493630

494631
#### Google Cloud SDK

0 commit comments

Comments
 (0)