If you want more control, deploy your application in your own customized Docker environment. Follow these steps:
App Readiness: Make sure your application is ready to be deployed by checking configurations, dependencies, and environment variables.
Docker Setup: Confirm that Docker is installed and set up on the machine where you plan to deploy your application.
There are two scenarios where the app is deployed on your own environment
Deployment from the app developer
From the root of the project run the below two commands for your app to be deployed and running
docker-compose up -d
Deployment from the user of app developed by another developer
Ensure that you have enough permission to access the docker image repository from the developer of the app.
In the terminal of your choice, run the below commands
docker pull <image_url>
docker run -d --name <container_name> -p <exposed_port> -p <exposed_port> --restart always <image_url>
Docker Run Command Explanation:
docker run command is used to start a Docker container based on a specified image. Below is an explanation of each option in the given command:
-d: This option runs the container in detached mode. It means the container runs in the background, allowing you to continue using the terminal for other commands without being attached to the container's console.
--name <container_name>: This option sets a custom name for the Docker container, making it easier to identify and reference.
-p <exposed_port> -p <exposed_port>: These options map ports on the host machine to ports on the container. Replace
<exposed_port>with the actual ports you want to expose. For example,
-p 80:80maps port 80 on the host to port 80 on the container.
--restart always: This option ensures that the container restarts automatically if it exits unexpectedly. It helps in maintaining the availability of the application.
<image_url>: Replace this with the actual URL or name of the Docker image you want to use for creating the container.
docker run -d --name my_container -p 8080:80 -p 3306:3306 --restart always my_image:latest
This example command starts a Docker container named "my_container" in detached mode, exposes host ports 8080 and 3306 to container ports 80 and 3306, respectively. It uses the "my_image:latest" Docker image and ensures that the container restarts automatically in case of unexpected exits.