Docker and "The OpenSSL library reported an error" when deployed Docker and "The OpenSSL library reported an error" when deployed docker docker

Docker and "The OpenSSL library reported an error" when deployed


These are the steps I've taken to make the deployment work on AWS.

I'm sure there are ways to optimize this and I will edit this post as I'll learn more about the process, but these are the steps I've taken.

  1. I built the binary on macOS:

    docker run -v $PWD:/volume -w /volume -e RUST_LOG="rusoto,hyper=debug" -e OPENSSL_STATIC=1 -e OPENSSL_DIR=/usr/local -e SSL_CERT_DIR=/etc/ssl/certs -t manonthemat/muslrust cargo build --release --features "logging"

  2. I modified the Dockerfile

    FROM alpine:edgeCOPY target/x86_64-unknown-linux-musl/release/project /RUN apk update && apk add --no-cache pkgconfig openssl-dev ca-certificates linux-headers && update-ca-certificatesCMD [ "/project" ]

  3. I built the docker image

    • I then pushed the docker image to a private repo and pulled it via ssh-session on the EC2 instance for testing. I ran it successfully via docker run -e SSL_CERT_DIR=/etc/ssl/certs secretuser/secretrepo:notsosecrettag
  4. I tagged and pushed the docker image to the AWS repository

  5. For a successful run on Amazon Elastic Container Service, I had to modify the task definition. In the containerDefinitions I had to up the memory and add this into the environment array:

    `{  "name": "SSL_CERT_DIR",  "value": "/etc/ssl/certs"}`
  6. For some unknown and probably unrelated reason I also had to update the agents on the EC2 instances and then restart those.


try running

update-ca-certificates in the image

like:

FROM scratchADD target/x86_64-unknown-linux-musl/release/project /RUN update-ca-certificatesCMD ["/project"]