Docker commands I use the most and think are the most relevant to get you going.
$ docker build -t IMAGE_NAME .
$ docker run IMAGE_NAME
$ docker run --name IMAGE_NAME -it IMAGE_NAME:TAG /bin/bash
Note: Append variables by adding -e
$ docker run -e "DW_HOST=" -e "DW_PORT=" -e "DW_USER=" -e "DW_PASS=" -e "DW_DB=" -e "EMAIL_SERVER=" -e "EMAIL_FROM=" -e "EMAIL_USERNAME=" -e "EMAIL_PASSWORD=" -e "ACCESS_KEY_ID=" -e "SECRET_ACCESS_KEY=" IMAGE_NAME:TAG
$ docker run -e "DW_HOST=" -e "DW_PORT=" -e "DW_USER=" -e "DW_PASS=" -e "DW_DB=" -e "EMAIL_SERVER=" -e "EMAIL_FROM=" -e "EMAIL_USERNAME=" -e "EMAIL_PASSWORD=" -e "ACCESS_KEY_ID=" -e "SECRET_ACCESS_KEY=" --name IMAGE_NAME:TAG -it IMAGE_NAME:TAG /bin/bash
$ docker push IMAGE_NAME/REPO_NAME:TAG
Make sure you can run aws
in your terminal first.
FROM python:3.5.2
RUN curl https://s3.amazonaws.com/aws-cloudwatch/downloads/latest/awslogs-agent-setup.py -o "awslogs-agent-setup.py"
COPY ./awslogs.conf awslogs.conf
RUN python awslogs-agent-setup.py --region eu-west-1 -c awslogs.conf
COPY requirements.txt ./
RUN pip install -r requirements.txt
COPY . .
ENTRYPOINT [ "entry.sh" ]
echo "Starting AWS logs..."
service awslogs start
service awslogs status
echo "Running app..."
python main.py
Run docker images
to retrieve the docker id's
Run docker rmi image_id_here
Run docker ps -a
to retrieve container id
Run docker rm container_id_here
There is a docker exec command that can be used to connect to a container that is already running.
Use docker ps
to get the name of the existing container
Use the command docker exec -it <container name> /bin/bash
to get a bash shell in the container
Generically, use docker exec -it <container name> <command>
to execute whatever command you specify in the container.
The proper way to run a command in a container is:
$ docker-compose run <container name> <command>.
For example, to get a shell into your web container you might run docker-compose run web /bin/bash
$ docker logs --tail 50 container_id