Docker has become an essential tool for developers to package and deploy applications. However, managing Docker images often requires dealing with registries (Dockerhub, AWS ECR, etc) that demand sign-ups and come with various limitations. What if you could use a Docker image registry that is free, anonymous, and ephemeral, without the need for any sign-up?
This guide will walk you through the process of creating, tagging, and pushing Docker images to ttl.sh, ensuring your images remain accessible temporarily.
if you have a docker image you can skip to, Generate a unique UUID section
git clone https://github.com/docker/docker-nodejs-sample
Create a Dockerfile
# Use an official Node.js runtime as a parent image
ARG NODE_VERSION=18.0.0
FROM node:${NODE_VERSION}-alpine
ENV NODE_ENV production
# Set the working directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
# Install dependencies
RUN npm install
USER node
# Bundle app source
COPY . .
# Expose the port your app runs on
EXPOSE 3000
# Define the command to run your app
CMD node src/index.js
Build the image
docker build -t mydockerimage .
Generate a unique UUID for image
here we are using uuidgen to generate a unique image name to reduce discoverability.you can give your image any name
IMAGE_NAME=$(uuidgen)
echo $IMAGE_NAME
Tag the Image
docker tag mydockerimage ttl.sh/${IMAGE_NAME}:1h
Image tags provide the time limit. The default is 24 hours, and the max is 24 hours (valid time tags :5m, :1600s, :4h, :1d)
Push an Images
docker push ttl.sh/${IMAGE_NAME}:1h
Pull an Image
docker pull ttl.sh/${IMAGE_NAME}:1h
If you found this guide helpful and want to stay updated with more tips and tricks for efficient development, be sure to subscribe to our newsletter. Don't miss out on the latest insights and tools to enhance your coding and Cloud journey!