Docker install link https://docs.docker.com/docker-for-mac/install/#what-to-know-before-you-install use Get Docker for Mac (Stable)

After you install Docker check if Docker is installed correctly by running command

 $ docker --version (You will get the docker version number)

To install Tomcat 8 on Docker run the following command.

$ docker image pull tomcat:8.0

To install Tomcat 7 on Docker run the following command.

$ docker image pull tomcat:7.0

To install Tomcat 8.0 on Docker run the following commands. The following will install a Docker container called dock-tomcat-8.0 and run on port 8080. To access use http://localhost:8080 on web browser.

$ docker container create --publish 8080:8080 --name dock-tomcat-8.0 tomcat:8.0

To install Tomcat 7.0 on Docker run the following command. The following will install a Docker container called dock-tomcat-7.0 and run on port 8082. To access use http://localhost:8082 on web browser.

$ docker container create --publish 8082:8080 --name dock-tomcat-7.0 tomcat:7.0

Command to check if MySQL docker instance is running

$ docker ps -a

Command to start tomcat 8 docker instance run

$ docker start dock-tomcat-8.0

Command to start tomcat 7 docker instance run

$ docker start dock-tomcat-7.0

Command to stop docker tomcat 8 instance

$ docker stop dock-tomcat-8.0

Command to stop docker tomcat 7 instance

$ docker stop dock-tomcat-7.0

To access docker tomcat 8 container directory

$ docker container exec -it dock-tomcat-8.0 bash

To access docker tomcat 7 container directory

$ docker container exec -it dock-tomcat-7.0 bash

To upload a WAR file and create an image

Create a folder under Documents directory.
Copy your war file in there (Eg. project.war).
Create a file in it called Dockerfile with following contents in it. This will use the base tomcat image and add the war file when published.

FROM tomcat:8.0

LABEL maintainer="info@example.com"

ADD project.war /usr/local/tomcat/webapps/

EXPOSE 8080

CMD ["catalina.sh", "run"]

Create an image with name flairbots-project for your application (Eg. Flair Bots project module) from Dockerfile. You need to be in the folder that contains the war file and the Docker file.

$ docker image build -t flairbots-project ./

Check if the image was created

$ docker image ls

Create and run the container with name (Eg. flairbots-project) from the newly created image on port 8085

$ docker container run -it --publish 8085:8080 --name flairbots-project flairbots-project

or to create and run in 2 steps use following commands

$ docker container create --publish 8085:8080 --name dock-tomcat-flairbots-project flairbots-project:latest

$ docker start flairbots-project

Application can be accessed from http://localhost:8085