From local webapp Rocket with Rust last week, to getting the whole thing into production. If there's one thing I've learned over the last year, it's that any evaluation/project/proto-type/mockup/thing is best examined by taking it from localhost all the way to **PROD** before making any rash decisions. I'm not going to lie, this was really difficult to accomplish.
Get Docker installed
If you get an error the next time you start your WSL terminal don’t freak out. It’s a bug with 18.03 and you can easily fix it. Hit
CTRL+Shift+ECS
to open task manager, goto the “Services” tab, find the “LxssManager” service and restart it.
Get Rocket Running in Docker locally
docker build -t friendlyhello . # Create image using this directory's Dockerfile
docker run -p 4000:80 friendlyhello # Run "friendlyname" mapping port 4000 to 80
docker run -d -p 4000:80 friendlyhello # Same thing, but in detached mode
docker container ls # List all running containers
docker container ls -a # List all containers, even those not running
docker container stop # Gracefully stop the specified container
docker container kill # Force shutdown of the specified container
docker container rm # Remove specified container from this machine
docker container rm $(docker container ls -a -q) # Remove all containers
docker image ls -a # List all images on this machine
docker image rm # Remove specified image from this machine
docker image rm $(docker image ls -a -q) # Remove all images from this machine
docker login # Log in this CLI session using your Docker credentials
docker tag username/repository:tag # Tag for upload to registry
docker push username/repository:tag # Upload tagged image to registry
docker run username/repository:tag # Run image from a registry
Get Container running somewhere else?
New Tactic, since it appears to be running, but I can’t hit it from the outside
docker run hello-world —> cool that works fine. ugh
To generate this message, Docker took the following steps:
Cheat Sheet
## List Docker CLI commands
docker
docker container --help
## Display Docker version and info
docker --version
docker version
docker info
## Execute Docker image
docker run hello-world
## List Docker images
docker image ls
## List Docker containers (running, all, all in quiet mode)
docker container ls
docker container ls --all
docker container ls -aq
Winning hand
docker build -t hello-rocket .
docker run --rm -p 8080:8080 -it --name running-rocket hello-rocket
FROM rustlang/rust:nightly
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . .
EXPOSE 8080
RUN rustc --version && cargo build
# CMD [ "cargo", "run" ]
# CMD cargo run
CMD ROCKET_ENV=development cargo run
There it is. the willing combination!!!!!!!
So, does a compiled language need to be in a container
The Promise NO VM’s
JavaScript to Elm
Jesse Tomchak