-
How to build a docker image ?
- from a dockerfile in the same directory and the image with name testing and version v1.3.0
docker build -t testing:v1.3.0 .
- from a dockerfile in the specified path and build the docker image in this directory:
docker build -t testing:v1.3.0 -f docker/Dockerfile .
-
How to run docker container and open its terminal ?
docker run -it busybox sh
-
Example 1:
FROM python:3 ENV PYTHONUNBUFFERED 1 RUN mkdir /code WORKDIR /code COPY requirements.txt /code RUN pip install -r requirements.txt COPY . /code CMD python run.py
-
If you are dockerizing a flask script, change the host ip addres from "192.1.0.0" to "0.0.0.0".
app.run(host="0.0.0.0", port=5000, debug=os.environ.get("debug")=='1')
here we also give port address and take debug variable from environment
-
If you dockerize flask, when you run the command expose the flask port to outside computer.
docker run -p 5000:5000 -e DEBUG=1 flask_app_dev # -e DEBUG gives the environment variable DEBUG a value of 1
-
How to stop a container ?
docker stop 838456456
stops the docker container with the given id
-
How to look at the logs in the container ?
docker logs container_id #or docker logs container_name
-
How to create a container with a name given by you ?
docker run --name kelbecer redis:latest
-
How to open a running container's shell ?
docker exec -it container_id /bin/bash
-
What is the difference between
docker run
anddocker start
?-->
docker run
creates a container from an image-->
docker start
is for starting a container, that is already created -
What is
docker network
and how to create adocker network
?# Docker network allows two containers inside a dockerfile to connect with each other docker network create mongo-network # this will create a docker network named mongo-network
-
To create a mongo container with environmental variables and also connect it to a network:
docker run -d -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=password --name mongodb --net mongo-network mongo # here: # -e is used to give environmental variables # --net is used to connect to a network
-
How to remove a docker image ?
docker rmi image_id
-
How to start a docker-compose from a file ?
docker-compose -f docker-compose.override.yml up
-
How to debug in docker-compose ?
- add stdin_open:true and tty:true inside the service
services: autocorrect: stdin_open: true tty: true command:
- start the docker-compose:
docker compose -f test.yml up
- Call the started container:
docker attach container_id
-
How to assign the port of the container to the local machine ?
docker run -p 3000:3000 test_image
docker build -t gcr.io/bghntr-speech-recognition/testing .
docker push gcr.io/bghntr-speech-recognition/testing
gcloud ai-platform jobs submit training mytestingmodell --region us-west1 --master-image-uri 'gcr.io/bghntr-speech-recognition/testing:latest' --scale-tier=CUSTOM --master-machine-type=n1-standard-8 --master-accelerator=type=nvidia-tesla-t4,count=2 --job-dir gs://my-test-models/mytestingmodell -- --model-name='finetuned-bert-classifier'
gcloud ai-platform jobs submit training indianwav2vec --region us-west1 --master-image-uri 'gcr.io/bghntr-speech-recognition/testspeechbig:latest' --scale-tier=CUSTOM --master-machine-type=n1-standard-8 --master-accelerator=type=nvidia-tesla-t4,count=4 --job-dir gs://my-test-models/indianwav2vec -- --model-name='wav2vecindian'
docker build -t sepen --build-arg data_path=gs://stt_train_data --build-arg train_data_path=indian_train_data.csv --build-arg audio_path=gs://voiceloft_amazon_data/media --build-arg test_data_path=indian_test_data.csv .