zhanpengwang888/Docker-Test
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
master
Could not load branches
Nothing to show
Could not load tags
Nothing to show
{{ refName }}
default
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code
-
Clone
Use Git or checkout with SVN using the web URL.
Work fast with our official CLI. Learn more about the CLI.
- Open with GitHub Desktop
- Download ZIP
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Docker Test for creating a dev server for an existing project. (I am going to test it with ticha project) Here are the steps to setup a dev server: 1. Install Docker to your computer/laptop 2. Create a working directory for projectname-Docker 3. Inside the directory, create a txt file named Dockerfile with the following contents: For Flask: # Use an official Python runtime as a parent image FROM python:2.7-slim # Set the working directory to /app WORKDIR /app # Copy the current directory contents into the container at /app ADD . /app # Install any needed packages specified in requirements.txt RUN pip install -r requirements.txt # Make port 80 available to the world outside this container EXPOSE 80 # Define environment variable ENV NAME World # Run app.py when the container launches CMD ["python", "app.py"] # change the name of "app.py" accordingly For Django: FROM python:3 ENV PYTHONUNBUFFERED 1 RUN mkdir /code WORKDIR /code ADD requirements.txt /code/ RUN pip install -r requirements.txt ADD . /code/ *Note: For Django, besides using Dockerfile, we also need to create a docker-compose.yml with the following contents: version: '3' services: db: image: postgres web: build: . command: python3 manage.py runserver 0.0.0.0:8000 volumes: - .:/code ports: - "8000:8000" depends_on: - db 4. Make sure that the Dockerfile, the app.py, and the requirement.txt in the same directory 5. Run the command docker build -t "projectname" 6. Run the app docker run -p 4000:80 "projectname" You should see a notice that the app is running at http://localhost:4000. 7. To share your image, you should tag the image so Docker can find it by running this command: docker tag image username/repository:tag # replace username with your username, repository with your repository, and tag name. 8. If you want to publish the image, you should push the tagged image to the repository by running this command: docker push username/repository:tag Once completed, your image is publicly visible. 9. To pull the image, just run this command: docker run -p 4000:80 username/repository:tag because Docker will automatically pull the image from the Docker repository.
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published