Cloud Native 8 min read

Step-by-Step Guide to Building and Running a Tomcat 7 Docker Container with MyEclipse

This tutorial explains how to install Docker and MyEclipse, create a Dockerfile for a Tomcat 7 image, build and run the container, deploy a Spring Shopping Cart example inside it, and use MyEclipse features to manage and test the Dockerized web application.

DevOps
DevOps
DevOps
Step-by-Step Guide to Building and Running a Tomcat 7 Docker Container with MyEclipse

Docker containers package applications with all required dependencies, making deployment, management, portability, and micro‑service support much easier.

Install Docker Toolbox on macOS or Windows, ensure the whale icon appears, and verify the installation with the hello‑world container.

Download and install the latest MyEclipse trial, then use Examples On‑Demand to add the Spring Shopping Cart example.

Create a DockerResources folder in the project and add a Dockerfile containing:

# We'll be using the curated Tomcat 7 container from DockerHub
FROM tomcat:7

Configure MyEclipse’s terminal to use a login shell (Arguments: -l), open a terminal in DockerResources, and set the Docker environment:

$ eval $(docker-machine env default)
$ docker version
Client:
Version: 1.11.1
API version: 1.23
Go version: go1.5.4
Git commit: 5604cbe
Built: Tue Apr 26 23:44:17 2016
OS/Arch: darwin/amd64

Server:
Version: 1.11.1
API version: 1.23
Go version: go1.5.4
Git commit: 5604cbe
Built: Wed Apr 27 00:34:20 2016
OS/Arch: linux/amd64

Build the Docker image:

$ docker build -t myeclipse/examples:run
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM tomcat:7
---> 705d4a88eedc
Successfully built 705d4a88eedc

Run the container, mapping host port 8080 to the container’s Tomcat port:

$ docker run -d -p 8080:8080 myeclipse/examples:run
12b15728e8adab5e49e484524a319f7349275f3165294161c3118220801ea7

Check running containers with docker ps and obtain the Docker host IP via docker-machine env:

$ docker-machine env
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/Users/todd/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"

When finished, stop the container: $ docker stop cranky_mcnulty Configure the SpringShoppingCartExample deployment in MyEclipse: add a new external Tomcat server named “Docker Tomcat 7 Container”, set the deployment location to /Applications/DockerDeployments, and ensure the status shows “Synchronized”.

Run the container again with a volume mapping so Tomcat can see the deployed application:

$ docker run -v "/Users/todd/Applications/DockerDeployments/SpringShoppingCartExample":/usr/local/tomcat/webapps/SpringShoppingCartExample -p 8080:8080 -d myeclipse/examples:run

Open a browser to http://192.168.99.100:8080/SpringShoppingCartExample/ to verify the web app runs inside the Docker container.

MyEclipse 2016 CI 4 also provides drag‑and‑drop Docker command snippets from the Snippets view, greatly speeding up the workflow.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockerspringContainerTomcatTutorialMyEclipse
DevOps
Written by

DevOps

Share premium content and events on trends, applications, and practices in development efficiency, AI and related technologies. The IDCF International DevOps Coach Federation trains end‑to‑end development‑efficiency talent, linking high‑performance organizations and individuals to achieve excellence.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.