Muhammad Yasir Amin

Loading websiteโ€ฆ

More from Muhammad Yasir Amin

Build Along With Me

Practical walkthroughs on Laravel, React, APIs and deployment workflows.

Subscribe on YouTube

Laravel Docker: Push a Docker Image to Docker Hub

๐Ÿ› ๏ธ Laravel Tutorials4 min read

Laravel Docker: Push a Docker Image to Docker Hub

Muhammad Yasir Amin

Muhammad Yasir Amin

Senior Full Stack Engineerโ€ขNov 6, 2026
Laravel Docker: Push a Docker Image to Docker Hub

To push a Laravel Docker image to Docker Hub, build the image with a name that starts with your Docker Hub username, log in with docker login, and run docker push username/laravel-app:1.0.0. Tag the image with a version number, not only latest, so you can roll back. The steps below cover the build, tagging, login, push and a pull test.

I assume a Laravel 13 app (PHP 8.3 or newer) that already has a working Dockerfile. Pushing an image is useful when a server, a CI job or a teammate should pull a ready build instead of building it again.

What do I need before I start?

  • Docker installed and running.
  • A free Docker Hub account and a repository name in mind, for example yourname/laravel-app.
  • A Dockerfile in the project root and a .dockerignore file.

Step 1: What should .dockerignore contain?

Keep secrets and bulky folders out of the image. A common starting point:

Shell
.git
.env
node_modules
vendor
storage/logs/*
storage/framework/cache/*
tests

Excluding .env matters. A pushed image can be pulled by anyone if the repository is public, and even in a private repository you do not want secrets baked into layers. Install vendor inside the image with Composer instead of copying your local folder.

Step 2: How do I build the image?

Code
docker build -t yourname/laravel-app:1.0.0 .

The format is username/repository:tag. The tag is your version label. If you already built the image under another name, add a second name without rebuilding:

Code
docker tag laravel-app:latest yourname/laravel-app:1.0.0

Step 3: How do I log in to Docker Hub?

Code
docker login

Enter your username and a password or a personal access token. A token is safer than your account password because you can limit and revoke it. In CI, store the token as a secret and pass it on standard input with --password-stdin so it does not appear in shell history:

Shell
echo "$DOCKERHUB_TOKEN" | docker login -u yourname --password-stdin

Step 4: How do I push the image?

Code
docker push yourname/laravel-app:1.0.0

Docker uploads each layer once. Layers that already exist on Docker Hub are skipped, so later pushes are faster when only your application code changed. To also publish a moving tag:

Shell
docker tag yourname/laravel-app:1.0.0 yourname/laravel-app:latest
docker push yourname/laravel-app:latest

I did not run these commands against a real Docker Hub account for this article. They follow the Docker CLI documentation.

Step 5: How do I prove the push worked?

  1. Open the repository page on Docker Hub and check that the tag 1.0.0 is listed with a recent push time.
  2. Remove the local copy: docker rmi yourname/laravel-app:1.0.0.
  3. Pull it back: docker pull yourname/laravel-app:1.0.0.
  4. Run it: docker run --rm -p 8000:80 yourname/laravel-app:1.0.0 and open the page. The exact port depends on how your image serves PHP.

Should the repository be public or private?

Use private for application code. A free Docker Hub account includes a limited number of private repositories, so check the current limits on your plan. Public is fine for open source projects, as long as no secret ever entered the image.

How should I name and version tags?

  • Use semantic versions such as 1.4.2 for releases.
  • Optionally add the short Git commit hash for traceability.
  • Treat latest as a convenience, not as something production depends on.
  • Never overwrite a version tag that was already deployed.

What are the common mistakes?

  • Wrong image name. Without your username prefix, Docker tries to push to a repository you do not own and returns an access error.
  • "denied: requested access to the resource is denied". You are not logged in, or the repository belongs to another account.
  • Secrets in the image. A COPY . . without a .dockerignore can copy .env into a layer. Check with docker history.
  • Pushing a dev image. Build a production image with composer install --no-dev and optimised autoload.
  • Using only latest. You cannot tell what is deployed, and rollback is guesswork.
  • Architecture mismatch. An image built on an Apple Silicon laptop may not run on an amd64 server. Build for the target platform with docker buildx build --platform linux/amd64.

FAQ

How do I push a Laravel image to a private registry instead?

Include the registry host in the image name, for example registry.example.com/team/laravel-app:1.0.0, run docker login registry.example.com, then push.

Can I push from GitHub Actions?

Yes. Store the Docker Hub token as a repository secret and use the official Docker login and build-push actions. Keep the token scope as narrow as possible.

Does pushing include my database data?

No. An image contains the filesystem built from your Dockerfile. Data in volumes stays on the machine where the container ran.

References

Article Index & Topic Tags
DockerLaravelDockerhubDeployment

YouTube Channel

Build Along With Me

Practical walkthroughs on Laravel, React, APIs and deployment workflows.

Muhammad Yasir Amin
Available for Contracts
Author & Solutions Architect

Senior Full Stack Engineer

Independent Senior Full Stack Engineer working on Laravel, React and Next.js applications, APIs and delivery workflows.

Laravel & PHP ApplicationsReact & Next.js InterfacesREST APIs & IntegrationsDatabase Queries & DebuggingDocker Development WorkflowsClear Scope & Handover
Discuss Your Next Step

What Does Your Application Need Next?

Share your current system, the problem you want to solve and what a useful result looks like. We can identify the right starting point and agree on a practical scope.

Technical Audit

Find the Next Useful Fix

Application Development

Scoped, Reviewable Milestones

Ongoing Support

Agreed Capacity and Priorities

Share your goals, current stack and requirements before the call.