How to Run "MarkLogic " In Docker - Tutorial
Exact Steps and Docker Tips & Ticks
Learn how to run MarkLogic docker containers with simple and easy to follow, step by step instructions.
We also cover docker tips/tricks, docker logs, docker run commands and more.
We split this tutorial into two sections, the Quick Docker Instructions and Detailed Docker Instructions for running MarkLogic in docker.
Quick Docker Instructions
Docker Cheatsheet style commands as these are some of the most often used docker commands for MarkLogic . Be sure to bookmark this tutorial, as you will find that these docker commands become very useful as you start your journey with running and maintaining MarkLogic in Docker.Detailed Docker Instructions
If this is the first time, you're running MarkLogic in Docker, please follow the detailed instructions, which explains what each command does. We made this Tutorial to be flexible and will work even if some details change with MarkLogic version/image. Which is why, we have specified commands to display available Ports, Volumes and Environment variables so you can always check what's available in the MarkLogic image before running the commands.Quick Docker Steps/Tricks:
Step 1
docker run -d --name marklogic1 marklogic:latest
Step 2
docker ps --filter name=marklogic1
Step 3
docker inspect marklogic1 | grep -A12 "State"
Step 4
docker logs marklogic1
Step 5
docker inspect -f "{{ .Config.ExposedPorts }}" marklogic1
Step 6
docker inspect -f "{{ .Config.Volumes }}" marklogic1
Step 7
docker inspect marklogic1 | grep -A50 "Env"
Step 8
docker stop marklogic1
Step 9
docker start marklogic1
Step 10
docker pause marklogic1
Step 11
docker unpause marklogic1
Step 12
docker exec -it marklogic1 /bin/sh
Step 13
docker commit marklogic1 my-custom-marklogic1:latest
Step 14
docker rm -f marklogic1
Step 15
docker rmi -f marklogic
Step 16
All of these are important and docker commands used most often. However, it does take a lot of manual work to run and maintain docker apps. If you're planning on using docker more often, we suggest to use ZoomAdmin to create/deploy and maintain docker apps.
ZoomAdmin is a cloud-cloud based control panel that allows you to easily deploy docker apps on to your own servers, map domain names to apps, create SSL Certificates and much more.
Check out ZoomAdmin Features for list of features and demo videos. And you can start with the Free Plan.
ZoomAdmin is a cloud-cloud based control panel that allows you to easily deploy docker apps on to your own servers, map domain names to apps, create SSL Certificates and much more.
Check out ZoomAdmin Features for list of features and demo videos. And you can start with the Free Plan.
Execute the docker commands for MarkLogic above step by step on as needed basis.
You can simply hit the copy button to copy the command and paste into the command line interface.
Note: see the details for each line below. docker rm commands will delete/remove the MarkLogic app. Be sure to read and understand what each line does below.
Note: see the details for each line below. docker rm commands will delete/remove the MarkLogic app. Be sure to read and understand what each line does below.
Detailed Instructions:
Step 1
This command will get the latest version of MarkLogic and run it.
-d option runs it in the background, so you don't need to keep your ssh session open. And
--name will name the container marklogic1. This is useful because all future commands will use the container name to interact this this container. Otherwise, you'd need to use randomly generated container id.
Note: We're simply running the barebone version of MarkLogic container with below command, after which, we will use the commands bellow to learn more about the MarkLogic docker container and then we'll be able to come-up with the final command to run based on our needs, to spin-up a properly configured MarkLogic container.
-d option runs it in the background, so you don't need to keep your ssh session open. And
--name will name the container marklogic1. This is useful because all future commands will use the container name to interact this this container. Otherwise, you'd need to use randomly generated container id.
Note: We're simply running the barebone version of MarkLogic container with below command, after which, we will use the commands bellow to learn more about the MarkLogic docker container and then we'll be able to come-up with the final command to run based on our needs, to spin-up a properly configured MarkLogic container.
docker run -d --name marklogic1 marklogic:latest
Step 2
Now that we ran the command to run the container, we need to check its status.
This command will only display the status for marklogic1 container.
Run docker ps without the filter, to display all running containers on the system.
This command will only display the status for marklogic1 container.
Run docker ps without the filter, to display all running containers on the system.
docker ps --filter name=marklogic1
Step 3
There is another way to check the status/state of the container and that's with docker inspect.
Sometimes, if the container exits or crashes, they may not be listed with docker ps, unless you do docker ps --all
But use the this docker inspect command to get more details on marklogic1 container status.
But use the this docker inspect command to get more details on marklogic1 container status.
docker inspect marklogic1 | grep -A12 "State"
Step 4
One of the most frequently docker command used is docker logs.
docker logs command is used to retrieve the logs output from the container. If there are any errors or issues or to check on the console output from the container, use the docker logs command.
Use the docker logs command below to display the logs for marklogic1 container.
docker logs command is used to retrieve the logs output from the container. If there are any errors or issues or to check on the console output from the container, use the docker logs command.
Use the docker logs command below to display the logs for marklogic1 container.
docker logs marklogic1
Step 5
In most cases, docker containers must expose a port so that it can be mapped with host machine's ports. This allows for interact with container app from outside the container.
MarkLogic documentation should show which ports are exposed, however, the most reliable way is for you to check the exposed ports directly from the running container. Use the command below to displays the exposed ports, which you can then use to map with host computer's ports.
MarkLogic documentation should show which ports are exposed, however, the most reliable way is for you to check the exposed ports directly from the running container. Use the command below to displays the exposed ports, which you can then use to map with host computer's ports.
docker inspect -f "{{ .Config.ExposedPorts }}" marklogic1
Step 6
Docker Volumes are also essential for running docker containers in production. Essentially, they allow you to map host computer's folder directly inside container. This helps with maintaining state or data of the container.
For instance, if marklogic1 container crashes for any reason, the data produced by this app will be lost. The solution is to use Volumes so that even if the container crashes, the data will reside outside of the container, hence, it will be preserved.
To properly use Volumes, they must be configured by the creators of the docker image, in this case, by MarkLogic image creators. The best way to find the available volumes already configured in marklogic1 container is by using the command below. Which will list the available volumes for you to use and potentially map with host computer's directories.
For instance, if marklogic1 container crashes for any reason, the data produced by this app will be lost. The solution is to use Volumes so that even if the container crashes, the data will reside outside of the container, hence, it will be preserved.
To properly use Volumes, they must be configured by the creators of the docker image, in this case, by MarkLogic image creators. The best way to find the available volumes already configured in marklogic1 container is by using the command below. Which will list the available volumes for you to use and potentially map with host computer's directories.
docker inspect -f "{{ .Config.Volumes }}" marklogic1
Step 7
Environment Variables are also an essential part of docker containers. In fact, it is a best practice to use Environment Variables for any dynamic configuration options. This includes, important settings, usernames, password, database connection settings and so on.
MarkLogic docker documentation should explain the available Environment Variables for MarkLogic image. However, it's sometimes best to just check and see what are all available and configured Env Variables for marklogic1 container.
Use the commands below to display all configured Environment Variables for marklogic1 container and their default values if any. I usually like using the first command, as the result is well formatted, but it's not as precise and may include extra json. Use both options when not sure.
MarkLogic docker documentation should explain the available Environment Variables for MarkLogic image. However, it's sometimes best to just check and see what are all available and configured Env Variables for marklogic1 container.
Use the commands below to display all configured Environment Variables for marklogic1 container and their default values if any. I usually like using the first command, as the result is well formatted, but it's not as precise and may include extra json. Use both options when not sure.
docker inspect marklogic1 | grep -A50 "Env"
docker inspect -f "{{ .Config.Env }}" marklogic1
Step 8
Docker Stop command is used to shutdown a container, it's like shutting down the computer. However, it is not removed and data/configuration is maintained, you can start the container when needed.
Stopping a container also removes it from some of the default places shown, i.e. if you do docker ps, it will not show there by default anymore.
Stopping a container also removes it from some of the default places shown, i.e. if you do docker ps, it will not show there by default anymore.
docker stop marklogic1
Step 9
Docker Start will start the container, just like the name suggests. It's self-explanatory and you can use the command below.
docker start marklogic1
Step 10
Docker Pause command does not stop the container, instead it suspends all processes on marklogic1 container, and it's much quicker to UnPause it and get it running again.
docker pause marklogic1
Step 11
Docker UnPause will simply un-pause our marklogic1 container and make it run again.
docker unpause marklogic1
Step 12
One of the most important and useful features of docker containers is being able to get shell access to the container. Once you get the shell access, you can directly interact with the container.
This is one of the most often used features because often, you'll need to go into the shell of the container and run commands, install additional software, change configuration, look at logs, etc.
Just keep in mind, if you install or change anything inside the container outside of the Volume folders, you will lose those changes if the container crashes or when you re-deploy it. Essentially, by installing/altering the container, you have now modified it and have a custom container.
However, it's still a very useful command.
To get shell access to our marklogic1 container, run the command below.
This is one of the most often used features because often, you'll need to go into the shell of the container and run commands, install additional software, change configuration, look at logs, etc.
Just keep in mind, if you install or change anything inside the container outside of the Volume folders, you will lose those changes if the container crashes or when you re-deploy it. Essentially, by installing/altering the container, you have now modified it and have a custom container.
However, it's still a very useful command.
To get shell access to our marklogic1 container, run the command below.
docker exec -it marklogic1 /bin/sh
Step 13
In our prior Step, we discussed how MarkLogic container can be modified from the shell access. But what if you want to keep those changes that are not in the Volume folders.
There is a way to do that as well. Use the command below to essentially save the state of the marklogic1 container and give it a custom name, i.e. my-custom-marklogic1.
There is a way to do that as well. Use the command below to essentially save the state of the marklogic1 container and give it a custom name, i.e. my-custom-marklogic1.
docker commit marklogic1 my-custom-marklogic1:latest
Step 14
When you're doing with all your testing or want to remove/delete marklogic1 container, use the command below.
Docker rm will remove and delete the container and its contents/data.
If you have configured Volumes, this will NOT delete the volume data on host computer. This will only remove marklogic1 container.
Docker rm will remove and delete the container and its contents/data.
If you have configured Volumes, this will NOT delete the volume data on host computer. This will only remove marklogic1 container.
docker rm -f marklogic1
Step 15
Even if you remove/delete marklogic1 container with docker rm command, it will not delete the actual MarkLogic base image that was downloaded to be used for marklogic1. It caches it locally, so if you spin-up a second MarkLogic container, it wouldn't need to download the base image again.
But sometimes you need to also remove these to save space on the host computer. Use the command below to remove MarkLogic image.
But sometimes you need to also remove these to save space on the host computer. Use the command below to remove MarkLogic image.
docker rmi -f marklogic
Step 16
All of these are important and docker commands used most often. However, it does take a lot of manual work to run and maintain docker apps. If you're planning on using docker more often, we suggest to use ZoomAdmin to create/deploy and maintain docker apps.
ZoomAdmin is a cloud-cloud based control panel that allows you to easily deploy docker apps on to your own servers, map domain names to apps, create SSL Certificates and much more.
Check out ZoomAdmin Features for list of features and demo videos. And you can start with the Free Plan.
ZoomAdmin is a cloud-cloud based control panel that allows you to easily deploy docker apps on to your own servers, map domain names to apps, create SSL Certificates and much more.
Check out ZoomAdmin Features for list of features and demo videos. And you can start with the Free Plan.