This is an example RESTful API microservice written in Python 3 and Flask
136
Open a Terminal window (Mac, Linux) or CMD window (Windows) and place yourself in the directory where the source code of your project is. Then, type the following command:
docker build . -t my_api:v1
where:
"." represents the current directory where you are
"-t" means you want to tag your container image with name
"my_api" is the main name of your container image
"v1" is the part of the tag name related to the container version
Open a Terminal window (Mac, Linux) or CMD window (Windows) and type:
docker run -p 5000:5000 my_api:v1 -it api_container
where:
"my_api:v1" is the local image you want to run as a container
"api_container" is the name you want to assign to this container image when it is run.
Open a Terminal window (Mac, Linux) or CMD window (Windows) and type:
docker exec -it <container_id> ash
NOTE: ash is the built-in shell in Alpine linux.
FROM alpine:3.8
MAINTAINER Jonathan Gonzalez <[email protected]> @EA1HET
RUN apk add --no-cache python3 \
&& python3 -m ensurepip \
&& pip3 install -U pip \
&& rm -rf /usr/lib/python*/ensurepip \
&& rm -rf /root/.cache \
&& rm -rf /var/cache/apk/* \
&& find / \
\( -type d -a -name test -o -name tests \) \
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
-exec rm -rf '{}' + \
&& mkdir /app
EXPOSE 5000
WORKDIR /app
COPY . /app
RUN pip install --no-cache-dir -r requirements.txt
ENTRYPOINT /app/boot.sh
Content type
Image
Digest
Size
14 MB
Last updated
about 8 years ago
docker pull ea1het/my_api:v1