Skip to content

Instantly share code, notes, and snippets.

@dsdanielpark
Last active June 1, 2023 09:27
Show Gist options
  • Save dsdanielpark/5d34b2f53709a7007b0d3a5e9f23c0a6 to your computer and use it in GitHub Desktop.
Save dsdanielpark/5d34b2f53709a7007b0d3a5e9f23c0a6 to your computer and use it in GitHub Desktop.
making docker file

docker --version It can be slightly different depending on the Docker version and programs such as cmd, powershell, linux, etc. Check it through the help command and modify it little by little.

Check This Useful Repository!
https://github.com/DSDanielPark/GPT-BERT-Medical-QA-Chatbot/blob/main/README.md

Docker hub

  1. https://hub.docker.com/
  2. https://docs.docker.com/engine/reference/commandline/manifest/
  3. docker image https://docs.docker.com/language/nodejs/run-containers/
  4. docker compose https://docs.docker.com/compose/gettingstarted/

How To Use

  1. making docker file and write down some command.
FROM python:3.9-slim

WORKDIR /app

RUN pip install --upgrade setuptools
RUN pip install --upgrade pip

RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    software-properties-common \
    git \
    && rm -rf /var/lib/apt/lists/* 

RUN pip install --upgrade pip

RUN git clone https://github.com/DSDanielPark/GPT-BERT-Medical-QA-Chatbot.git .

RUN pip3 install -r requirements.txt

EXPOSE 8501

HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health

ENTRYPOINT ["streamlit", "run", "chatbot.py", "--server.port=8501", "--server.address=0.0.0.0"]
  1. tagging name
  • in my case, chatgpt is image name
docker build -t chatgpt .
  1. check
docker scan #args
docker scan --version
  1. image check
docker images
  1. docker run
  • run with port porting
docker run -p 8501:8501 -v ${PWD}/:/usr/src/app/data chatgpt 

Using Docker Compose

docker-compose.yml

version: '1.0'

services:
  streamlit:
    build:
      dockerfile: dockerfile
    ports:
      - '8501:8501'
    volumes:
      - './:/usr/src/app/data'
    environment:
      - USER_ID=1000
      - GROUP_ID=1000
 docker compose up -d
 docker compose ps

5000/tcp The docker compose run command allows you to run one-off commands for your services. For example, to see what environment variables are available to the web service:

 docker compose run web env

See docker compose --help to see other available commands.

If you started Compose with docker compose up -d, stop your services once you’ve finished with them:

 docker compose stop

You can bring everything down, removing the containers entirely, with the down command. Pass --volumes to also remove the data volume used by the Redis container:

 docker compose down --volumes

check powershell or cmd and venv, with proper version.

Other command

docker ps


docker ps -a

docker rm [container-id]

docker images


docker rmi [img-id]


docker ps -a -q

docker container ls -a

docker container ls -aq 



docker container stop $(docker container ls -aq)
docker container rm $(docker container ls -aq)



docker kill $(docker ps -q)
docker_clean_ps
docker rmi $(docker images -a -q)



#Delete system cached
docker system prune -a

docker image prune


#Remove All Docker Containers
docker container stop $(docker container ls -aq) && docker system prune -af --volumes


#Removing Docker Images With Filters
docker image prune -a --filter "until=24h"

https://phoenixnap.com/kb/remove-docker-images-containers-networks-volumes

$ streamlit hello

  You can now view your Streamlit app in your browser.

  Local URL: http://localhost:8501
  Network URL: http://192.168.1.51:8501
  

Path finding

find / -name [folderfindingkeyword] -type d 


find ./ -name [folderfindingkeyword] -type d


ls -Rhal | grep [filefindingkeyword]

 
ls | grep [keyworkd] | xargs rm   

Docker Pushing to hub after tagging

docker tag [dockerImageName] [dockerHubId/repositoryName]
docker push [dockerHubId/repositoryName]

Docker pull and deploy without docker compose

docker pull [dockerHubId/repositoryName]
docker images
docker images [dockerHubId/repositoryName]
docker run -p 8501:8501 -v ${PWD}/:/usr/src/app/data [taggingName] 
....
....
# hard working.........do not recommanded

Docker compose push

Hub name must be in imaeg as follows

version: '1.0'

services:
  medical-chatgpt-streamlit-v1:
    build:
      dockerfile: dockerfile
    ports:
      - '8501:8501'
    volumes:
      - './:/usr/src/app/data'
    environment:
      - USER_ID=1000
      - GROUP_ID=1000
      
    image: parkminwoo91/medical-chatgpt-streamlit-v1:latest
docker compose build
docker compose push

Delete all

 docker stop $(docker ps -a -q)

 docker rm $(docker ps -a -q)
 docker rmi $(docker images -q) 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment