-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_docker.sh
33 lines (27 loc) · 1.12 KB
/
run_docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
#
# Bash script to generate requirements.txt file, build docker image and launch container.
# author: AndreasDemenagas (@AndreasDemenagas)
# date: October 27th 2022
#
# Copyright (C) 2022 SUFST
#
env -i
# The following commands got used craft the venv reqruirements.
# Uncomment if necessary.
#
# Activates the Virtual Environment
# source venv/bin/activate
# Freezes pip and generates a requirements.txt file with dependencies.
# This file will be used later on to install everything in the Docker container
# pip freeze > requirements.txt
# deactivate
# Builds the Docker image, giving it the name `sufst-back-end`
docker build -t sufst-back-end .
# Stops existing containers with the same name and removes them from Docker.
docker stop sufst-back-end
docker rm sufst-back-end
# Runs the container from the built image and exposes port 5000 to the local machine's port 5000
# Assigns localhost to host.docker.internal (host.docker.internal = the localhost of the host machine)
# host-gateway = alias to my localhost
docker run --add-host host.docker.internal:host-gateway -p 5000:5000 -it --rm --name sufst-back-end sufst-back-end