skip to Main Content

I am trying to manage a multi container project. At some point I get this error that I don’t understand. I tried getting the logs but there was none.

version: "3.7"
services:
  api:
    build: ../api
    command: sh -c "rails s"
    working_dir: /app
    depends_on:
      - database
    networks:
      - citrine-api
      - citrine-front
    ports:
      - 3000:3000
    volumes:
      - type: bind
        source: ../api
        target: /app
  front:
    build: ../frontend
    command: sh -c "yarn dev"
    depends_on:
      - api
    networks:
      - citrine-front
    volumes:
      - type: bind
        source: ../frontend
        target: /app
    ports:
      - 5173:5173
  database:
    image: keinos/sqlite3
    networks:
      - citrine-api
    ports:
      - 3306:3306
networks:
  citrine-api: {}
  citrine-front: {}

strconv.Atoi: parsing "": invalid syntax

The images build from local are simple dockerfiles.

Does anyone have an idea to correct that ?

4

Answers


  1. I also faced the same issue. There was no error except for:

    strconv.Atoi: parsing "": invalid syntax
    

    Scenario:

    • a go project
    • dockerfile
    • docker-compose.yaml
    • Windows 10 with docker-desktop

    The following command will stop and delete all the docker containers that are not defined in docker compose file. There might be many useful containers running in your system that were not created by the docker-compose file or were created by someone else. Use this command with caution!

    Solution:

    docker-compose down --remove-orphans
    

    Explaination:
    For some reason, the docker-compose create some unknown containers along with service. This command remove those unknown problematic containers.

    Login or Signup to reply.
  2. Use it at your own risk:

    docker-compose down --remove-orphans
    
    Login or Signup to reply.
  3. I resolved by doing:
    docker system prune

    This command might be safer than docker-compose command.

    Login or Signup to reply.
  4. I faced the same issue and fixed it, one of the solution might work for you.


    STEP-1
    But in my application I had only one service with one image in my compose file and ran the compose file, so it created container1 and ran the image.


    STEP-2
    I used the same image and ran it in a different directory with new environ variables, without a compose file and it created a container2 and ran the image.


    STEP-3
    Then when make changes in my compose file like environment variables and compose up again, it gives me the same error.


    STEP-4
    So, when I deleted the second container and ran compose up, then it works.


    STEP-5
    when you run compose up, it is trying to rerun the container that it created when you ran the compose file for the first time and if you created a new container in mean while then it is not able to access it, I don’t know why.
    Then it throws this error.


    SOLUTION FOR MY ISSUE: I just deleted the container-2, and ran the compose up and it got access to the container-1, which was created when I ran compose up for that particular compose file for the first time and it ran successfully.


    SOLUTION-1:As you have 3 images, delete all the containers of the images that you have in compose file and compose up, it will work for sure.


    SOLUTION-2:Delete the containers of the images in the compose file that exited and you are not using, it might or might not work.


    SOLUTION-3:Delete all the containers of the images in the compose file and compose up again, check for the containers it created and mark them, and in the future if you receive the same error in the process of development, just delete all the other other containers of the images in the compose file except the marked ones.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search