1. Create dockerfile
:~/yoon/dockerfile/
2. Create requirement.txt
elasticsearch==7.15.0
pandas==1.2.4
prefixspan==0.5.2
numpy==1.21.3
urllib3==1.26.7
mlxtend==0.19.0
3. Clone my project
Local : Edit code → git add . → git commit → git push origin main
$ git add .
$ git commit -m "modified requirement file"
[main 829c970] modified requirement file
3 files changed, 420 insertions(+), 451 deletions(-)
$ git push origin main
Counting objects: 7, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 1.87 KiB | 1.88 MiB/s, done.
Total 7 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5), completed with 5 local objects.
To https://github.com/mellamonaranja/PrefixSpan
2069764..829c970 main -> main
Remote server : git pull origin main
$ git pull origin main
Username for 'https://github.com': mellamonaranja
Password for 'https://mellamonaranja@github.com':
remote: Enumerating objects: 13, done.
remote: Counting objects: 100% (13/13), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 7 (delta 5), reused 7 (delta 5), pack-reused 0
Unpacking objects: 100% (7/7), done.
From https://github.com/mellamonaranja/PrefixSpan
* branch main -> FETCH_HEAD
2069764..829c970 main -> origin/main
Updating 2069764..829c970
Fast-forward
FP_Growth_accident/FP_Growth_20210925.ipynb | 859 ++++++++++++++++++++++++++++-----------------------------
PrefixSpan_accident/PrefixSpan_20211021.ipynb | 9 -
requirements.txt | 3 +-
3 files changed, 420 insertions(+), 451 deletions(-)
4. create Dockerfile
FROM python:3.9.7 #(Image, any image is ok)
WORKDIR /usr/src #WORKDIR is where I want to run inside the container, same as cd, therefore it means cd /usr/src
COPY ./requirements.txt . #copy [requirements.txt] in my host current directory to WORKDIR
RUN pip install -r requirements.txt #-r is requirement
COPY ./PrefixSpan_accident . #copy [PrefixSpan_accident] in my host current directory to WORKDIR
RUN ls #show me the list
CMD ["PrefixSpan_20211021.py"]
ENTRYPOINT ["python3"]
- CMD : Command, it can be written multiple times on Dockerfile, however, it executes the last CMD(overrided)
- ENTRYPOINT : It executes no matter run command
reference : https://williamjeong2.github.io/blog/10-docker-run-vs-cmd-vs-entryporint/
5. docker build
Once I have the Dockerfile saved, I need to run it locally.
$ docker build -t prefixspan:0.1 .
free(): invalid pointer
...
Successfully built 0d0531c4749f
Successfully tagged prefixspan:0.1
-t : Tag, name and optionally a tag in the 'name:tag' format
6. docker run
$ docker run -it prefixspan:0.1 PrefixSpan_20211021.py
'Docker' 카테고리의 다른 글
Docker Project 1-Docker environment, build, volume, logs (0) | 2021.11.08 |
---|---|
Run container with environment variable (0) | 2021.11.02 |
commit, tag, dockerfile, build, filter (0) | 2021.09.13 |
Install the docker-compose (0) | 2021.04.12 |
MAC address, VLAN, LAN, -d, --driver, --subnet, --ip-range, -o, (0) | 2021.02.23 |