Skip to content

Latest commit

 

History

History
279 lines (218 loc) · 5.02 KB

steps-to-deploy-locally-on-docker.md

File metadata and controls

279 lines (218 loc) · 5.02 KB

steps-to-deploy-locally-on-docker

install docker

	curl -fsSL https://get.docker.com -o get-docker.sh

	sudo sh get-docker.sh

	sudo usermod -aG docker ubuntu

	newgrp docker

    docker --version

download image

docker pull ubuntu

Create and start docker container interactive and detach with code mapping for ubuntu image

docker run -dit -p 8080:8080 ubuntu /bin/bash

to list all containers

docker ps -a

to go into docker conatiner

docker exec -it <container_id> /bin/bash

docker exec -it 46faaa72e730 /bin/bash

update container

apt-get update -y
apt-get upgrade -y
apt-get install curl unzip -y

install aws cli

curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"
unzip -u awscliv2.zip
./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update
which aws
ls -l /usr/local/bin/aws
aws --version

choose you region and country when prompt

configure aws configuration

aws configure

AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY=/9fmfoI3U AWS_DEFAULT_REGION=us-east-1

Since model upload after training and application will download model from s3, hence we need to configure

AWS_ACCESS_KEY_ID=<your-access-key>
AWS_SECRET_ACCESS_KEY=<your-secret-access-key>
AWS_DEFAULT_REGION=us-east-1
export MONGODB_URL="mongodb+srv://mayankchughlearning:[email protected]/?retryWrites=true&w=majority&appName=Cluster0"
export AWS_ACCESS_KEY_ID=""

export AWS_SECRET_ACCESS_KEY=""

export AWS_DEFAULT_REGION="us-east-1"

## install python      
```bash
apt-get install python3-full -y

install pip

apt-get install pip -y
apt-get install mesa-utils -y

install git nano vim

apt-get install git -y
apt-get install nano -y
apt-get install vim -y

git clone

git clone https://github.com/mayankchugh-learning/US-Visa-Approval-Prediction.git

change directory to clonned repository

cd US-Visa-Approval-Prediction
python3 -m venv path/to/venv
source path/to/venv/bin/activate

install all requirement - Note: you may need to comment line with notebook

pip install -r requirements.txt

to check if aws cli is installed

aws --version

exist from docker and then go into docker conatiner

docker ps -a
docker exec -it <container_id> /bin/bash

docker exec -it 46faaa72e730 /bin/bash

execute application

python3 app.py

to list all containers

docker ps -a

to go into docker conatiner - Skip this step

docker exec -it <container_id> /bin/bash

Exit Docker Container without Stopping It

  • If you want to exit the container's interactive shell session, but do not want to interrupt the processes running in it, press Ctrl+P followed by Ctrl+Q. This operation detaches the container and allows you to return to your system's shell
docker commit <container_id>

docker commit 46faaa72e730 mayankchughjob/end-to-end-usvisa-prediction-mlmodel

docker image tag <image_id> <dockerhubid>/<name on dockerhub>:latest

docker image tag 8a5162116265 mayankchughjob/end-to-end-object-detection:latest

docker push <image id>

docker push mayankchughjob/end-to-end-usvisa-prediction-mlmodel

Commands to pull image from docker hub and run it locally

docker pull mayankchughjob/end-to-end-usvisa-prediction-mlmodel:latest
docker run -dit -p 8080:8080 mayankchughjob/end-to-end-usvisa-prediction-mlmodel /bin/bash

to list all containers

docker ps -a

to go into docker conatiner

docker exec -it <container_id> /bin/bash

docker exec -it 582ca9056a26 /bin/bash

cd End-to-end-Object-Detection-Project/
source path/to/venv/bin/activate
python3 app.py

docker image

https://docs.docker.com/engine/reference/commandline/image/#examples

to list all images

docker image ls

docker command line interface (cli)

https://docs.docker.com/engine/reference/commandline/


 AWS_ACCESS_KEY_ID=
 AWS_SECRET_ACCESS_KEY=
 AWS_DEFAULT_REGION=

to stop all running container (reference only)

docker stop $(docker ps -a -q)

to remove all stopped container (reference only)

docker rm $(docker ps -a -q)

to remove all images

docker rmi $(docker images -a -q)

to list all containers (reference only)

docker ps -a

to list all images (reference only)

docker image ls

docker-compose

https://docs.docker.com/compose/

dockerfile

https://docs.docker.com/engine/reference/builder/#run
docker ps -a
docker restart <container_id>  #8f1a99a79b3d
docker exec -it <container_id> /bin/bash
# docker exec -it 8f1a99a79b3d /bin/bash
source path/to/venv/bin/activate
python3 app.py