Chapter 4. Starting and Stopping the Container

Once you have downloaded the JBoss EAP image, you can execute the docker run command to start up a container based on that image. By default, if you start a JBoss EAP container with no arguments, it will start a standalone JBoss EAP instance with the jboss.bind.address bound to 0.0.0.0.

Start a Base JBoss EAP Instance

$ docker run registry.access.redhat.com/jboss-eap-7-tech-preview/eap70

This starts the container and attaches to it. To stop this container, press Ctrl+C in the terminal where it was started. Alternatively, you may start a container in detached mode using the -d option.

Start a Detached Base JBoss EAP Instance

$ docker run -d registry.access.redhat.com/jboss-eap-7-tech-preview/eap70

To see all running containers, use the docker ps command.

List Running Docker Containers

$ docker ps

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                            NAMES
0e0a93c7455f        my-eap-image        "/opt/eap/bin/standal"   6 minutes ago       Up 6 minutes        0.0.0.0:8080->8080/tcp, 0.0.0.0:9990->9990/tcp   distracted_mietner

Once a container is running, you can stop or reattach to it using the docker stop CONTAINER_ID and docker attach CONTAINER_ID commands.

Stop a Detached Base JBoss EAP Instance

$ docker stop 0e0a93c7455f

Publishing Ports

When you start a container, by default it will receive its own IP address on a separate docker network interface. You have the option to have any of the container’s ports published to your host’s ports so they are accessible using your host’s address. This is accomplished using -p hostPort:containerPort.

Example Port Publishing

$ docker run -p 18080:8080 registry.access.redhat.com/jboss-eap-7-tech-preview/eap70

The above example publishes port 8080 in the container to port 18080 on the host.

Important

By default, the JBoss EAP image ships with only the public interface bound to 0.0.0.0 (-b 0.0.0.0). See the Extending the Image section for more details on binding to additional interfaces. You will need to do this before you can publish additional ports such as the management interface port.

You can also publish multiple ports at the same time as well as publish to the same port on the host.

Example Port Publishing

$ docker run -p 8080:8080 -p 9990:9990 registry.access.redhat.com/jboss-eap-7-tech-preview/eap70

The above example publishes ports 8080 and 9990 from the container to the same ports on the host.

Note

You can also publish all exposed ports from the container to the host using -P.

Important

If you want access any interfaces on the JBoss EAP instance running the container, for example the HTTP interface on 8080 or the management port on 9990, you need to publish that port. The addition of Undertow in JBoss EAP 7 added HTTP Upgrade and allows for multiple protocols to be multiplexed over of a single port. JBoss EAP 7 moved nearly all of its protocols to be multiplexed over ports 8080 and 9990 so access to WebSockets, remoting EJB invocations, JMS, JMX, and AJP are also available when you publish those ports.