Coder Social home page Coder Social logo

docker-ltmj's Introduction

background

to standard and simple building and running java web in dev/pro env.

dependences

some important soflt need to be prepared:

database for mysql

  • hostname: mysql

the state will add a host resovle in the db cm mysql, in file /etc/hosts with content xxx.xx.xx.xx mysql. it will map the address http://mysql to the db cm mysql,equals to http://localhost in the db cm mysql

data for persistence

the data in cm will destory when the cm is destory, you need to make volume maping from cm path to your pm path in docker-compose.yml:

  • /var/lib/mysql the db cm mysql data file path must to mount to your pm path
  • /usr/local/tomcat/logs the serve cm tomcat log file path .you can mount to your pm path too
  • /data the db cm redis data file path
  • /data/activemq the db cm activemq data file path will map the address http://mysql to the db cm mysql,equals to http://localhost in the db cm mysql

project simple usage

after debuging the project,start with -d arg to run in backgroud process. you also can use docker-compose logs -f to get start log.

# run in backgroud process
docker-compose up -d

# get the start log
docker-compose logs -f

some important solft for java web

  • JAVA1.8
  • Tomcat8.5.41
  • mavenmaven:3.6.1-jdk-8
  • MySQL10.3.15
  • Redis5.0.7
  • ActiveMQ5.14.3

the maven you can update it in init-conf.sh file. the other solft version updated in docker-compose.yml file or Dockerfile file

# fetch from a remote image
# image: redis:5.0.7
# build image with a local config
  build: ./redis

after updating docker-compose.yml file or Dockerfile file,need to rebuild image .you can run as below but not last:

docker-compose up --build

the project dir construtor

javaweb-compose/
├── activemq
│   ├── data  # pm data path mount to cm
│   ├── Dockerfile   # the image conf file
│   └── logs   # pm log path mount to cm
├── docker-compose.yml  # docker-compose  conf file
├── mysql
│   ├── conf  # pm conf path mount to cm
│   ├── data  # pm data path mount to cm
│   └── Dockerfile   # the image conf file
├── README.md
├── redis
│   ├── conf   # pm conf path mount to cm
│   ├── data  # pm data path mount to cm
│   └── Dockerfile
└── tomcat
    ├── conf    # pm conf path mount to cm
    ├── Dockerfile   # image conf file
    ├── logs   # pm log path mount to cm
    └── webapps
        └── ROOT   # tomcat default project ROOT dir
……………

docker-ltmj's People

Contributors

ymc-github avatar

Watchers

 avatar  avatar

docker-ltmj's Issues

2019-12-16 08:13:35

2019-12-16 08:13:35

desc

get err when run image in vm

expected

Starting xxx    ... done

actual

ERROR: for nginx-1.17-alpine  a bytes-like object is required, not 'str'

ERROR: for nginx  a bytes-like object is required, not 'str'
Traceback (most recent call last):
  File "site-packages/docker/api/client.py", line 261, in _raise_for_status
  File "site-packages/requests/models.py", line 940, in raise_for_status
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http+docker://localhost/v1.22/containers/4e5bbce451720d688957fce5e67d30379648b7652ee261fb635bdaa3bf11be47/start

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "compose/service.py", line 625, in start_container
  File "compose/container.py", line 241, in start
  File "site-packages/docker/utils/decorators.py", line 19, in wrapped
  File "site-packages/docker/api/container.py", line 1095, in start
  File "site-packages/docker/api/client.py", line 263, in _raise_for_status
  File "site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
docker.errors.APIError: 500 Server Error: Internal Server Error ("b'driver failed programming external connectivity on endpoint nginx-1.17-alpine (b5036045fcde103ededebe92e42cd080024d2981738925f0981656189a54b15c): Bind for 0.0.0.0:8080 failed: port is already allocated'")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "bin/docker-compose", line 6, in <module>
  File "compose/cli/main.py", line 72, in main
  File "compose/cli/main.py", line 128, in perform_command
  File "compose/cli/main.py", line 1107, in up
  File "compose/cli/main.py", line 1103, in up
  File "compose/project.py", line 570, in up
  File "compose/parallel.py", line 112, in parallel_execute
  File "compose/parallel.py", line 210, in producer
  File "compose/project.py", line 556, in do
  File "compose/service.py", line 568, in execute_convergence_plan
  File "compose/service.py", line 510, in _execute_convergence_start
  File "compose/parallel.py", line 112, in parallel_execute
  File "compose/parallel.py", line 210, in producer
  File "compose/service.py", line 508, in <lambda>
  File "compose/service.py", line 620, in start_container_if_stopped
  File "compose/service.py", line 627, in start_container
TypeError: a bytes-like object is required, not 'str'
[2136] Failed to execute script docker-compose

behavior

docker-compose up -d

my env

PM:WIN10
VM:CENTOS 7.7
CM:APLINE 3.xx
note:win+virtual+sharedir

find some thing:

#find factor for:Bind for 0.0.0.0:8080 failed: port is already allocated'
ps -aux | grep -v grep | grep docker-proxy
#> 172.20.1.2 -container-port 8080

#reason: nginx uses 8080:80 and tomcat uses 8080:8080

how to solve:

#update docker-compose.yml ports for nginx and tomcat serve

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.