Comments (1)
I am using the followings to do the healthcheck for cosmos. Build image from the official image, add some extra tiny bits to it, define a different start using entrypoint.sh and check for certificate.
Docker file
FROM mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
RUN apt-get update && \
apt-get -y install -y openssl && \
apt-get install -y procps iputils-ping net-tools && \
apt-get install -y wget && \
apt-get -y install gpg && \
rm -rf /var/lib/apt/lists/*
# Install tini
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc /tini.asc
RUN gpg --batch --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 595E85A6B1B4779EA4DAAEC70B588DFF0527A9B7 \
&& gpg --batch --verify /tini.asc /tini
RUN chmod +x /tini
# Create non-root user
RUN groupadd -g 1000 -r dev && \
useradd -u 1000 -r -g dev -m -s $(which bash) dev
# Option '-m' to create home directory (see https://askubuntu.com/a/393470)
# Option '-s' to set shell for this user (see comment in https://askubuntu.com/a/393470)
# Option '-r' creates a system user which does not expire (see https://linuxize.com/post/how-to-create-users-in-linux-using-the-useradd-command/)
# Doesn't need to expose ports as they are part of main image
EXPOSE 8081
EXPOSE 8901
EXPOSE 8902
EXPOSE 10250
EXPOSE 10251
EXPOSE 10252
EXPOSE 10253
EXPOSE 10254
EXPOSE 10255
EXPOSE 10350
# Create working directory. Ownership will be changed in entrypoint.sh which
# executes *after* the volume has been mounted.
RUN mkdir /src
# Copy entrypoint script into container, make it executable, then execute it:
COPY ./entrypoint.sh ./
RUN chmod +x ./entrypoint.sh
# Option '+x' adds executable flag to the file
CMD ./entrypoint.sh & ./start.sh
entrypoint.sh
#!/bin/sh
sleep 5s
#################################################################################################################
# Provided the Dockerfile doesn't change the user, this script will run as 'root'. However, once VS Code connects
# it will connect remotely as user 'dev' [Manfred, 19sep2021]
#################################################################################################################
# Change ownership of all directories and files in the mounted volume:
chown -R dev:dev /src
# Option '-R' applies the ownerhip change recursively on files and directories in /src
#################################################################################################################
# Retrieve the self-signed SSL certificate of the CosmosDB Emulator and install in dev container
#
echo Retrieving self-signed SSL certificate from CosmosDB Emulator
retry=1
while true; do
wget --no-check-certificate --output-document=/tmp/emulator.crt https://localhost:8081/_explorer/emulator.pem
if [ "$?" -eq 0 ]
then
echo "wget successful"
break
else
echo "******* Waiting for retry" $retry "*******"
sleep 5s
fi
retry=`expr $retry + 1`
done
# Copy to well-known location
cp /tmp/emulator.crt /usr/local/share/ca-certificates
# Remove symbol link to trigger update of ca-certificates.crt file.
# See http://manpages.ubuntu.com/manpages/xenial/man8/update-ca-certificates.8.html
rm -rf /etc/ssl/certs/emulator.pem
# Trigger update of file with concatenated list of certificates:
update-ca-certificates > /tmp/update-ca-certificates-result.txt
# To check if the previous result was successful, check content of file /tmp/update-ca-certificates-result.txt
#
# To confirm the certificate was correctly installed, use the following command from inside the dev container.
# Note that it doesn't use option '--no-check-certificate' which means, if successful, it used the certificate
# that was just installed:
# wget https://demo-database.local:8081/_explorer/emulator.pem
#
# To check certificate DNS entries in the self-signed certificate with the following command
# openssl x509 -noout -text -in /tmp/emulator.crt
#################################################################################################################
# Finally invoke what has been specified as CMD in Dockerfile or command in docker-compose:
"$@"
Compose file Health Check only
healthcheck:
test: ["CMD", "openssl", "x509", "-noout", "-text", "-in", "/tmp/emulator.crt"]
interval: 10s
timeout: 3s
retries: 10
from azure-cosmos-db-emulator-docker.
Related Issues (20)
- CosmosDB linux emulator docker container fails to start HOT 24
- Emulator Container Limit HOT 6
- Unable to connect to Cosmos DB emulator through VM when using AllowNetworking HOT 13
- Error response from daemon: manifest for microsoft/azure-cosmosdb-emulator:latest not found: manifest unknown: manifest unknown HOT 1
- Container starts and immediately stops on macOS HOT 3
- Linux docker container runs but function app CosmosDBTrigger does nothing. Windows msi does work. HOT 2
- AZURE_COSMOS_EMULATOR_PARTITION_COUNT is ignored HOT 1
- Linux container fails to start up with SIGABRT HOT 8
- Emulator cosmosDB does not start successfully HOT 1
- Azure Cosmos Emulator docker image is broken HOT 13
- Container is not ready after startup HOT 5
- Gremlin support for Linux HOT 2
- Unable to use Data Explorer with Windows Emulator and AllowNetworkAccess HOT 2
- Unable to use Mongo API when running in Docker Desktop HOT 1
- Large number of excludedPaths in index policy fails creation
- Trial expiring soon HOT 4
- Container hangs on... HOT 3
- Emulator Linux docker image is using an ancient version of CosmosDb emulator HOT 1
- Emulator Certificate Not Accessible - Emulator Not Running in Windows Container
- AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE flag is not respected. HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-cosmos-db-emulator-docker.