/python-ml-docker

docker, python, vm, lightgbm, xgboost

Primary LanguageDockerfile

python-ml-env-docker

I create environment for machine learning (xgboost, lightgbm) with docker.

how to activate python environment

  1. build images or restart container
  2. excecute container and show bash script of docker
  3. execute python script
// terminal
docker-compose up --build 
docker start -a [container id || container name] // contatiner already created
docker exec -it [container id || container name] bash // '-it': need intractive process like a shell

// container
python script/test.py

// terminal
docker stop [container id || container name] 

useful docker command

  • build, run options
docker build -t #{docker id}/#{project name}:#{version} . // set image name
docker run --name hoge -it hogehoge:latest // set container name
docker run -v #{host directory}:#{container directory} -it hogehoge:latest // use local file
docker run -d hoge // run images on background
  • commit (create image from container)
docker commit -c #{new order} [container] #{docker id}/#{project name}:#{version}
  • docker-compose
docker-compose up -d // launch in background
docker-compose dows // stop all container
docker-compose ps // use only directory as 'docker-compose.yml' file
  • remove containers or images
docker system prune // remove stopped container, not tags images, not uses volume and networks
docker container prune // remove stopped containers
docker image prune // remove stopped images

// remove the container or image
docker rm [container id]
docker rmi [image id]

useful git command

  • remove local changes
git checkout .
  • remove all file (back to commit)
git clean -df .
  • reset command

git add: working tree -> index git commit: index -> local repository git push: local repository -> remote repository

// reset latest commit
git reset --soft HEAD^

// reset latest commit, add, working tree
git reset --hard HEAD^

// reset all commit changes
git reset --hard HEAD

// reset all add changes
git reset --mixed HEAD

// remove reset
git reset --hard ORIG_HEAD

Feature Perspective

  • connect to AWS, Mysql, kubernetes
  • running lightgbm on docker and aws

Directory

├── Dockerfile
├── README.md
├── docker-compose.yml
├── mysql
│   ├── Dockerfile
│   ├── db
│   │   └── init.sql
│   └── my.cnf
└── script
    └── test.py

Option Technics

how to activate mysql database

  1. build images
  2. open command prompt
  3. open mysql and sql command
  4. reset db and remove container (better not to do?)
// terminal
docker-compose up --build
docker exec -it mysql-host bash

// mysql (container)
mysql -u [MYSQL_ROOT_PASSWORD] -p
show database;
use [table name];

//  terminal (reset db and remove container)
docker-compose down

Referrence