Docker doesn’t copy new images

I have a problem regarding Docker.

When I’m deploying a new version of my app image, the images i have added to the images folder in my wwwroot folder aren’t copied..

My Dockerfile looks like this:

FROM microsoft/aspnetcore-build:1.0-projectjson

WORKDIR /app-src
COPY . .

RUN dotnet restore
RUN dotnet publish src/Test -o /app

EXPOSE 5000
WORKDIR /app
ENTRYPOINT ["dotnet", "Test.dll"]

And my docker-compose:
version: '3.8'
services:
   app:
    image: <dockeruser>/<imagename>:<tag>
    links:
      - db
    environment:
      ConnectionStrings__Dataconnection: "Host=db;Username=Username;Password=Password;Database=db"
    ports:
      - "5000:5000"
    volumes:
      - ~/data/images:/app/wwwroot/images
   db:
    image: postgres:9.5
    ports:
      - "31337:5432"
    volumes:
      - ~/data/db:/var/lib/postgresql/data/pgdata
    environment:
      POSTGRES_USER: user
      POSTGRES_PASSWORD: password
      POSTGRES_DB: db
      PGDATA: /var/lib/postgresql/data/pgdata

My current version of docker is:
Docker version 18.09.7, build 2d0083d and docker-compose docker-compose version 1.26.2, build eefe0d31
The exact same files (except for the docker-compose version was set to 2 in docker-compose.yml) worked previously on docker version Docker version 17.03.0-ce, build 60ccb22 and docker-compose version docker-compose version 1.9.0, build 2585387

I store my new images in my repos wwwroot/images folder, and then push them to the repo, and then dockerhub automatically builds an image from the new commit. On the server i then pull the new docker-image and run the docker-compose down -v command followed by docker-compose up -d but the images is not available in the app afterwards.

Disclaimer: This is a project I have overtaken and I’m aware of some of the very old software versions.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Your images may be in your container image, but since you are doing a bind mount whatever is in your server’s “~/data/images” directory will basically “override/replace” what’s in your image when the container is created.

Try removing the volume from the app service, basically remove this:

volumes:
– ~/data/images:/app/wwwroot/images

The other thing you can try is to manually copy the images to the “~/data/images” directory on the server.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x