我要评分
获取效率
正确性
完整性
易理解

Using an Official Image for Deployment

The official Docker image site https://hub.docker.com/ provides TomEE images. The latest image tags that support the Kunpeng (ARM64v8) architecture include tomee:8-jre-8.0.0-M2-plus and tomee:8-jre-8.0.0-M2-plume. This section uses the tomee:8-jre-8.0.0-M2-plus tag as an example.

  1. Install the image.
    1
    docker pull tomee:8-jre-8.0.0-M2-plus
    
  2. View the information about the local image that has been obtained.
    1
    docker images
    
    REPOSITORY          TAG                   IMAGE ID            CREATED             SIZE
    tomee               8-jre-8.0.0-M2-plus   ff0e68ebc739        13 months ago       475MB
    • If the environment can access the Internet only through a proxy, configure environment variables for the proxy server and configure Docker.
      1. Create a directory.
        mkdir /etc/systemd/system/docker.service.d/
      2. Open the /etc/systemd/system/docker.service.d/http-proxy.conf file.
        vim /etc/systemd/system/docker.service.d/http-proxy.conf
      3. Add the following content to the file. Save the file and exit.
        [Service]
        Environment="http_proxy=http://youraccount:password@IP:PORT"
        Environment="https_proxy=https://youraccount:password@IP:PORT"
        Environment="NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp"

        In the preceding content, youraccount indicates a user name, password indicates a password, IP indicates a proxy IP address, and PORT indicates a proxy port.

      4. Restart the related services for the settings to take effect.
        1
        systemctl daemon-reload
        
        1
        systemctl restart docker
        

      If the error message "Get https://registry-1.docker.io/v2/: proxyconnect tcp: net/http: TLS handshake timeout" is still displayed after the proxy is configured, retain only the HTTP proxy during proxy configuration.

    • If the onsite environment cannot access the Internet, use a PC that can access the Internet to download the image and deploy the image to the target server.
  3. Create a container instance.
    1. Use the tomee:8-jre-8.0.0-M2-plus image to instantiate a container named mytomee. In the container, TomEE runs on port 8080.
      1
      docker create -it -p 8888:8080 --name mytomee tomee:8-jre-8.0.0-M2-plus
      

      -p 8888:8080 indicates that port 8080 inside a container is mapped to port 8888 outside the container so that external devices can access the TomEE service in the container through port 8888.

    2. View information about all created containers.
      1
      docker ps -a
      

  4. Run the created container instance.
    1. The container created using the docker create command does not automatically run after being created. You need to run the docker start container name command to run the container.
      1
      docker start mytomee
      
    2. View the running container.
      1
      docker ps
      

    1. After a container is created, run the container instance immediately.
      1
      docker run -itd -p 8888:8080 --name mytomee tomee:8-jre-8.0.0-M2-plus
      
    2. When the container is running, you can run the docker stop container name command to stop the container.
      1
      docker stop mytomee
      
  5. Verify the running of TomEE.

    When the mytomee container is running, use a browser on another PC in the same network segment as the server to access the Docker host machine through port 8888.

    Enter http://host IP:8888 in the address box of the browser. If the home page of the TomEE service is displayed, the TomEE service is successfully deployed and running on the Docker.

  1. If port 8888 is occupied, you can use another port.
  2. In the official image, the installation directory of TomEE is /usr/local/tomee/. The configuration file is located in the /usr/local/tomee/conf/ directory, and the web application (WAR files) can be deployed in the /usr/local/tomee/webapps directory.