Quickly Add MongoDB to Your App With Docker MongoDB is an open-source NoSQL database that stores data in JSON-like documents. NoSQL databases are a natural choice if you don’t know your data requirements upfront. They are also a good fit for applications like product catalogs or blog content. That’s where an object-oriented approach shines. Let’s see how we can easily add a Mongo database with Docker and Docker Compose.
I prefer to use Docker containers for running a PostgreSQL database. Spin up the container, develop the app, then tear down the container. The Postgres database doesn’t clutter up my local system, and I can easily set it up on a different machine. Using Docker Compose, I can configure the setup and commit it to source control. In this blog post, I’ll show you how to get a database up and running with Docker and Docker Compose.
Three days ago I started a short tutorial on how to write a test-driven Node.js web API with PostgreSQL database. The excellent blog post is from 2016, but it’s still useful. I used Docker to build the application. If you want to see the example application as a dockerized Node.js/Express.js program, you can take a look at my GitLab repository. The repository also uses GitLab CI to build the container and run the tests with Mocha.
Project Structure Here’s the project structure for my application. Adjust to your needs. I used the Express application generator to scaffold the program. . ├── docker-compose.yml ├── Dockerfile ├── healthcheck.js ├── LICENSE ├── node_app │ ├── app.js │ ├── bin │ │ └── www │ ├── db │ │ ├── Dockerfile │ │ ├── knex.js │ │ ├── migrations │ │ └── seeds │ ├── knexfile.js │ ├── node_modules │ ├── package.
Create a Docker container that runs your machine learning models as a web application This article will explain the advantages of Streamlit and how to build a Streamlit application with Docker. Why Streamlit? You’ve explored your data and developed a machine learning model. It’s now time to release it to the world so that others can see what you’ve built. Now what? Deploying machine learning models is not trivial.
Let Docker access the internet by passing through the VPN connection My host machine, a laptop running Manjaro Linux, is connected via VPN to the internet. I use strongSwan, the open-source IPsec-based VPN solution. IPsec with the IKEv2 protocol is fast and secure. Now, Docker doesn’t work. Networking issues are a common problem with VPN and Docker. You can piggyback your Docker container on the host network. That technique only works on Linux machines.
Docker builds containers via layers. All commands add another layer to the already existing image. What does that mean for changing file permissions via chown or chmod? Let’s say we build this image: FROMfrolvlad/alpine-miniconda3:python3.7 AS build## set working directoryWORKDIR/usr/src/app## copy codeCOPY ./code /codeCOPY ./notebooks /notebooks## add non-root userRUN addgroup –system user && \ adduser –system -G user user && \ chown -R user:user /usr/src/appAfter copying the code from the host machine to the container, we switch permissions for the working directory from root to user.