AWS ECS task can't access outbound - amazon-ecs

I created docker image that based on ubuntu:18.04
Maybe I think ECS task cannot access to outbound.
When I execute apt-get update, it throw errors.
root#ip-172-31-14-71:~# apt-get install -y wget
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libpsl5 publicsuffix
The following NEW packages will be installed:
libpsl5 publicsuffix wget
0 upgraded, 3 newly installed, 0 to remove and 2 not upgraded.
Need to get 455 kB of archives.
After this operation, 1320 kB of additional disk space will be used.
Err:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 libpsl5 amd64 0.19.1-5build1
Could not connect to archive.ubuntu.com:80 (91.189.88.162), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.149), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.161), connection timed out
Err:2 http://archive.ubuntu.com/ubuntu bionic/main amd64 publicsuffix all 20180223.1310-1
Unable to connect to archive.ubuntu.com:http:
Ign:3 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 wget amd64 1.19.4-1ubuntu2.2
Err:3 http://security.ubuntu.com/ubuntu bionic-updates/main amd64 wget amd64 1.19.4-1ubuntu2.2
Unable to connect to archive.ubuntu.com:http:
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libp/libpsl/libpsl5_0.19.1-5build1_amd64.deb Could not connect to archive.ubuntu.com:80 (91.189.88.162), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.149), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.161), connection timed out
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/p/publicsuffix/publicsuffix_20180223.1310-1_all.deb Unable to connect to archive.ubuntu.com:http:
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/w/wget/wget_1.19.4-1ubuntu2.2_amd64.deb Unable to connect to archive.ubuntu.com:http:
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
root#ip-172-31-14-71:~# apt-get install -y wget
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libpsl5 publicsuffix
The following NEW packages will be installed:
libpsl5 publicsuffix wget
0 upgraded, 3 newly installed, 0 to remove and 2 not upgraded.
Need to get 455 kB of archives.
After this operation, 1320 kB of additional disk space will be used.
Err:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 libpsl5 amd64 0.19.1-5build1
Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.161), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.162), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.149), connection timed out
Err:2 http://archive.ubuntu.com/ubuntu bionic/main amd64 publicsuffix all 20180223.1310-1
Unable to connect to archive.ubuntu.com:http:
Ign:3 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 wget amd64 1.19.4-1ubuntu2.2
Err:3 http://security.ubuntu.com/ubuntu bionic-updates/main amd64 wget amd64 1.19.4-1ubuntu2.2
Unable to connect to archive.ubuntu.com:http:
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libp/libpsl/libpsl5_0.19.1-5build1_amd64.deb Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.161), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.162), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.149), connection timed out
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/p/publicsuffix/publicsuffix_20180223.1310-1_all.deb Unable to connect to archive.ubuntu.com:http:
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/w/wget/wget_1.19.4-1ubuntu2.2_amd64.deb Unable to connect to archive.ubuntu.com:http:
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
wget to google.com also failed.
I do not configure any firewalls or related about that.
Is there any configuration for ECS task?

Related

Error accessing raspbian.raspberrypi.org when downloading packages

When I try to install anything on my Raspberry Pi 3 I get the following error message, I don't seem to have any trouble connecting to the Internet, as
ping google.com
and connecting to the pi via ssh work.
Is this a common error or am I missing anything?
admin#raspberrypi:~/Desktop $ sudo apt-get install motion
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
libfuse2
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
libmariadb3 libmicrohttpd12 libpq5 mariadb-common mysql-common
Suggested packages:
default-mysql-client postgresql-client
The following NEW packages will be installed:
libmariadb3 libmicrohttpd12 libpq5 mariadb-common motion mysql-common
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 947 kB of archives.
After this operation, 3,651 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf mysql-common all 5.8+1.0.7 [7,464 B]
Get:2 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf mariadb-common all 1:10.5.15-0+deb11u1 [36.7 kB]
Err:3 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf libmariadb3 armhf 1:10.5.15-0+deb11u1
Cannot initiate the connection to raspbian.raspberrypi.org:80 (2a00:1098:0:80:1000:75:0:3). - connect (101: Network is unreachable) Could not connect to raspbian.raspberrypi.org:80 (93.93.128.193), connection timed out [IP: 93.93.128.193 80]
Err:4 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf libmicrohttpd12 armhf 0.9.72-2
Cannot initiate the connection to raspbian.raspberrypi.org:80 (2a00:1098:0:80:1000:75:0:3). - connect (101: Network is unreachable) [IP: 93.93.128.193 80]
Err:5 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf libpq5 armhf 13.8-0+deb11u1
Cannot initiate the connection to raspbian.raspberrypi.org:80 (2a00:1098:0:80:1000:75:0:3). - connect (101: Network is unreachable) [IP: 93.93.128.193 80]
Err:6 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf motion armhf 4.3.2-1
Cannot initiate the connection to raspbian.raspberrypi.org:80 (2a00:1098:0:80:1000:75:0:3). - connect (101: Network is unreachable) [IP: 93.93.128.193 80]
Fetched 44.2 kB in 31s (1,438 B/s)
E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/m/mariadb-10.5/libmariadb3_10.5.15-0%2bdeb11u1_armhf.deb Cannot initiate the connection to raspbian.raspberrypi.org:80 (2a00:1098:0:80:1000:75:0:3). - connect (101: Network is unreachable) Could not connect to raspbian.raspberrypi.org:80 (93.93.128.193), connection timed out [IP: 93.93.128.193 80]
E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/libm/libmicrohttpd/libmicrohttpd12_0.9.72-2_armhf.deb Cannot initiate the connection to raspbian.raspberrypi.org:80 (2a00:1098:0:80:1000:75:0:3). - connect (101: Network is unreachable) [IP: 93.93.128.193 80]
E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/p/postgresql-13/libpq5_13.8-0%2bdeb11u1_armhf.deb Cannot initiate the connection to raspbian.raspberrypi.org:80 (2a00:1098:0:80:1000:75:0:3). - connect (101: Network is unreachable) [IP: 93.93.128.193 80]
E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/m/motion/motion_4.3.2-1_armhf.deb Cannot initiate the connection to raspbian.raspberrypi.org:80 (2a00:1098:0:80:1000:75:0:3). - connect (101: Network is unreachable) [IP: 93.93.128.193 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
This link may help. Either the server is dead or ipv6 isn’t working properly.
IPv6 Network is unreachable (os error 101)
Edit: You can try and add ipv6.disable=1 to the GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX entries in /etc/default/grub.cfg then run sudo update-grub. This way it will default to ipv4 and work properly.

Running MongoDB shell commands from within shell script connection refused

I have the following shell script which I am running in UserData section of a CloudFormation template:
#!/bin/sh
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list
apt-get update
apt-get install -y mongodb-org
apt install mongodb-clients
systemctl start mongod
systemctl status mongod
systemctl enable mongod
echo "ABOUT TO ENTER WHILE LOOP"
while :
do
echo "waiting to RUN MONGO COMMANDS"
echo "$(systemctl show -p ActiveState --value mongod)"
if [ "$(systemctl show -p ActiveState --value mongod)" = "active" ]
then
echo "RUNNING MONGO COMMANDS"
mongo crawler --eval "db.websites.insertOne({ customerId: '1', url: 'https://dootli.com' })"
mongo crawler --eval "db.createUser({ user: 'username', pwd: 'password', roles: 'clusterAdmin' })"
break
fi
done
As far I can tell the script is valid, how I'm getting the this output (and error) when it is run during the initialization of the EC2 instance:
Reading package lists...
Building dependency tree...
Reading state information...
The following package was automatically installed and is no longer required:
mongodb-database-tools
Use 'apt autoremove' to remove it.
The following additional packages will be installed:
libboost-filesystem1.71.0 libboost-iostreams1.71.0
libboost-program-options1.71.0 libgoogle-perftools4 libpcrecpp0v5
libsnappy1v5 libtcmalloc-minimal4 libyaml-cpp0.6 mongo-tools
The following packages will be REMOVED:
mongodb-org mongodb-org-database-tools-extra mongodb-org-mongos
mongodb-org-server mongodb-org-shell mongodb-org-tools
The following NEW packages will be installed:
libboost-filesystem1.71.0 libboost-iostreams1.71.0
libboost-program-options1.71.0 libgoogle-perftools4 libpcrecpp0v5
libsnappy1v5 libtcmalloc-minimal4 libyaml-cpp0.6 mongo-tools mongodb-clients
0 upgraded, 10 newly installed, 6 to remove and 87 not upgraded.
Need to get 35.2 MB of archives.
After this operation, 44.4 MB disk space will be freed.
Do you want to continue? [Y/n] Abort.
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: active (running) since Sat 2021-02-06 20:38:12 UTC; 15ms ago
Docs: https://docs.mongodb.org/manual
Main PID: 2738 (mongod)
Memory: 288.0K
CGroup: /system.slice/mongod.service
└─2738 /usr/bin/mongod --config /etc/mongod.conf
Feb 06 20:38:12 ip-172-31-64-168 systemd[1]: Started MongoDB Database Server.
Created symlink /etc/systemd/system/multi-user.target.wants/mongod.service → /lib/systemd/system/mongod.service.
ABOUT TO ENTER WHILE LOOP
waiting to RUN MONGO COMMANDS
RUNNING MONGO COMMANDS
MongoDB shell version v4.4.3
connecting to: mongodb://127.0.0.1:27017/crawler?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:374:17
#(connect):2:6
exception: connect failed
exiting with code 1
MongoDB shell version v4.4.3
connecting to: mongodb://127.0.0.1:27017/crawler?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:374:17
#(connect):2:6
exception: connect failed
exiting with code 1
Cloud-init v. 20.3-2-g371b392c-0ubuntu1~20.04.1 running 'modules:final' at Sat, 06 Feb 2021 20:37:42 +0000. Up 27.35 seconds.
ci-info: no authorized SSH keys fingerprints found for user ubuntu.
Cloud-init v. 20.3-2-g371b392c-0ubuntu1~20.04.1 finished at Sat, 06 Feb 2021 20:38:12 +0000. Datasource DataSourceEc2Local. Up 56.97 seconds
I modified the code to work. I identified that the main issue is mongodb-clients which causes failures of monogdb. Also your command db.createUser is invalid and will lead to failure as well. I did not fix that, as its not related to your issue about connection refused. You can make new question why your db.createUser is incorrect (I don't know how to fix that, its mongodb specific).
#!/bin/sh
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list
apt update
apt install -y mongodb-org
systemctl enable mongod
systemctl start mongod
echo "ABOUT TO ENTER WHILE LOOP"
while :
do
echo "waiting to RUN MONGO COMMANDS"
sleep 5
echo "$(systemctl show -p ActiveState --value mongod)"
if [ "$(systemctl show -p ActiveState --value mongod)" = "active" ]
then
echo "RUNNING MONGO COMMANDS"
mongo crawler --eval "db.websites.insertOne({ customerId: '1', url: 'https://dootli.com' })"
[ $? != 0 ] && continue
echo "db.websites.insertOne command successful"
break
fi
done

brew services start mongodb-community#4.2 Error: Unknown command: services

I am trying to run MongoDB by running brew services start mongodb-community#4.2 but I am getting the error that you see below:
jaimes-mbp:SMR jaimemontoya$ brew services start mongodb-community#4.2
==> Tapping homebrew/services
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 27, done.
remote: Counting objects: 100% (27/27), done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 27 (delta 0), reused 16 (delta 0), pack-reused 0
Unpacking objects: 100% (27/27), done.
Checking connectivity... done.
Tapped 0 formulae (63 files, 276K)
Error: Unknown command: services
jaimes-mbp:SMR jaimemontoya$
Isn't brew the command, and services only a parameter? I am not understanding why the error says that services is an unknown command. Thank you.
UPDATE 1: I see two warnings when I try to run brew install mongodb-community#4.2 again. Maybe that has something to do with the problem?:
jaimes-mbp:SMR jaimemontoya$ brew install mongodb-community#4.2
Warning: mongodb/brew/mongodb-community-4.2.3 already installed
Warning: You are using OS X 10.15.
We do not provide support for this pre-release version.
You may encounter build failures or other breakages.
UPDATE 2: When I use mongo, it is doing something:
jaimes-mbp:SMR jaimemontoya$ mongo
MongoDB shell version v4.2.3
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2020-03-13T06:41:22.073-0600 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:341:17
#(connect):2:6
2020-03-13T06:41:22.076-0600 F - [main] exception: connect failed
2020-03-13T06:41:22.076-0600 E - [main] exiting with code 1
jaimes-mbp:SMR jaimemontoya$
Maybe I do not need to use brew services start mongodb-community#4.2? I thought it was necessary to run MongoDB Community Edition.
UPDATE 3: I run ps aux | grep -v grep | grep mongod and it returns nothing. I am trying to verify that MongoDB is running, so I am searching for mongod in my running processes but it returns nothing, meaning that MongoDB is not running I guess.
UPDATE 4: See what happens when I run brew doctor --verbose:
Warning: You are using OS X 10.15.
We do not provide support for this pre-release version.
You may encounter build failures or other breakages.
Warning: Your Homebrew is outdated.
You haven't updated for at least 24 hours. This is a long time in brewland!
To update Homebrew, run `brew update`.
Warning: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil are known to do this.
You should probably change the ownership and permissions of /usr/local
back to your user account.
sudo chown -R $(whoami):admin /usr/local
When I run sudo chown -R $(whoami):admin /usr/local, I get this:
jaimes-mbp:SMR jaimemontoya$ sudo chown -R $(whoami):admin /usr/local
Password:
chown: /usr/local: Operation not permitted
jaimes-mbp:SMR jaimemontoya$
brew update is not working:
jaimes-mbp:SMR jaimemontoya$ brew update
Error: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil are known to do this.
You should probably change the ownership and permissions of /usr/local
back to your user account.
sudo chown -R $(whoami):admin /usr/local
jaimes-mbp:SMR jaimemontoya$
Seems like you are facing issue with brew.
Run brew doctor --verbose to check if the brew is working fine.
And then brew update to update the brew version.
After this run, brew services list to display all the services in the brew.
If you see mongodb-community#4.2 there in the list, then run brew services start mongodb-community#4.2
It should work.
I followed the advice MikeMcQuaid provided at https://github.com/Homebrew/brew/issues/3665:
You need to uninstall and install Homebrew using
https://github.com/Homebrew/install
As explained at https://github.com/Homebrew/install, I first ran /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)". After that I ran /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)".
Then I ran this:
jaimes-mbp:SMR jaimemontoya$ brew tap mongodb/brew
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
No changes to formulae.
==> Tapping mongodb/brew
Cloning into '/usr/local/Homebrew/Library/Taps/mongodb/homebrew-brew'...
remote: Enumerating objects: 86, done.
remote: Counting objects: 100% (86/86), done.
remote: Compressing objects: 100% (76/76), done.
remote: Total 145 (delta 41), reused 21 (delta 10), pack-reused 59
Receiving objects: 100% (145/145), 30.18 KiB | 2.16 MiB/s, done.
Resolving deltas: 100% (68/68), done.
Tapped 6 formulae (33 files, 83.0KB).
jaimes-mbp:SMR jaimemontoya$ brew install mongodb-community#4.2
==> Installing mongodb-community from mongodb/brew
==> Downloading https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.2.3.tgz
######################################################################## 100.0%
==> Caveats
To have launchd start mongodb/brew/mongodb-community now and restart at login:
brew services start mongodb/brew/mongodb-community
Or, if you don't want/need a background service you can just run:
mongod --config /usr/local/etc/mongod.conf
==> Summary
🍺 /usr/local/Cellar/mongodb-community/4.2.3: 21 files, 304.3MB, built in 1 minute 54 seconds
jaimes-mbp:SMR jaimemontoya$ brew services start mongodb-community#4.2
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 88, done.
remote: Counting objects: 100% (88/88), done.
remote: Compressing objects: 100% (47/47), done.
remote: Total 691 (delta 31), reused 69 (delta 25), pack-reused 603
Receiving objects: 100% (691/691), 192.79 KiB | 1.68 MiB/s, done.
Resolving deltas: 100% (270/270), done.
Tapped 1 command (39 files, 266.3KB).
==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-community)
jaimes-mbp:SMR jaimemontoya$ ps aux | grep -v grep | grep mongod
jaimemontoya 17763 0.1 0.2 5544164 38300 ?? S 8:11AM 0:00.65 /usr/local/opt/mongodb-community/bin/mongod --config /usr/local/etc/mongod.conf
jaimes-mbp:SMR jaimemontoya$
It works!

error while running the comannd 'psql' Error: You must install at least one postgresql-client-<version> package

When I run vagrant ssh and login successfully then try the ~$psql command, I get this error: Error: You must install at least one postgresql-client-<version> package.
I saw a similar question here and I ran this command:
~$ sudo apt-get install postgresql-client
The output:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libpq5 postgresql-client-9.1
Suggested packages:
postgresql-9.1 postgresql-doc-9.1
The following NEW packages will be installed:
libpq5 postgresql-client postgresql-client-9.1
0 upgraded, 3 newly installed, 0 to remove and 66 not upgraded.
Need to get 1,057 kB/1,063 kB of archives.
After this operation, 3,448 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Err http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libpq5 amd64 9.1.5-0ubuntu12.04
404 Not Found [IP: 91.189.91.23 80]
Err http://security.ubuntu.com/ubuntu/ precise-security/main libpq5 amd64 9.1.5-0ubuntu12.04
404 Not Found [IP: 91.189.88.149 80]
Err http://security.ubuntu.com/ubuntu/ precise-security/main postgresql-client-9.1 amd64 9.1.5-0ubuntu12.04
404 Not Found [IP: 91.189.88.149 80]
Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/p/postgresql-9.1/libpq5_9.1.5-0ubuntu12.04_amd64.deb 404 Not Found [IP: 91.189.88.149 80]
Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/p/postgresql-9.1/postgresql-client-9.1_9.1.5-0ubuntu12.04_amd64.deb 404 Not Found [IP: 91.189.88.149 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
I tried the suggested fix missing too but didn't work.
How can I install a postgresql package successfully? And mainly how can I get the $psql command to give me the desired output showed in the picture?
(Edit) I tried the first answer's suggestion:
vagrant#precise64:~$ apt-get update
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
Then tried the solutions mentioned here :
vagrant#precise64:~$ ps aux | grep apt
vagrant 1144 0.0 0.2 11676 948 pts/0 S+ 18:59 0:00 grep --color=auto apt
I don't understand so I don't know what's next.
looks like you had some trouble installing several packages 404 Not Found.
Do sudo apt-get update and then retry the install.

Upgrade to postgres96 on Alpine (/usr/bin/pg_dump: No such file or directory)

I'm trying to upgrade postgres locally so I don't get a version mismatch error. This is what i do:
echo "http://dl-5.alpinelinux.org/alpine/v3.5/main" >> /etc/apk/repositories;
apk update
bash-4.3# apk add postgresql-dev
(1/4) Installing libressl2.4-libtls (2.4.4-r0)
(2/4) Installing libressl-dev (2.4.4-r0)
(3/4) Installing postgresql-libs (9.6.5-r0)
(4/4) Installing postgresql-dev (9.6.5-r0)
Executing busybox-1.24.2-r13.trigger
OK: 353 MiB in 108 packages
bash-4.3# pg_dump
bash: /usr/bin/pg_dump: No such file or directory
I'm at a loss - any idea what the problem is please?
Just a guess but I guess you've not installed postgresql. In order to use the pg_dump you must have installed this, or if you do have it already and I'm wrong try reinstalling it like so:
bash-4.3# apk del postgresql
(1/4) Purging postgresql (9.6.5-r0)
(2/4) Purging postgresql-client (9.6.5-r0)
(3/4) Purging libedit (20170329.3.1-r2)
(4/4) Purging libxml2 (2.9.4-r4)
Executing busybox-1.26.2-r5.trigger
OK: 37 MiB in 25 packages
bash-4.3# apk add postgresql
(1/4) Installing libedit (20170329.3.1-r2)
(2/4) Installing postgresql-client (9.6.5-r0)
(3/4) Installing libxml2 (2.9.4-r4)
(4/4) Installing postgresql (9.6.5-r0)
Executing busybox-1.26.2-r5.trigger
OK: 53 MiB in 29 packages
bash-4.3# pg_dump
pg_dump: [archiver (db)] connection to database "root" failed: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
bash-4.3#
As you can see from above pg_dump is working because it is in the postgresql package even though as listed on alpine packages site it should be within the postgresql-client package as shown here but it doesn't work unless postgres is installed. If you can't have a full postgres installation, I recommend this workaround which is a bit unclean, install postgres, backup the pg_dump binary, uninstall postgres then restore pg_dump like so:
bash-4.3# apk add postgresql
(1/2) Installing libxml2 (2.9.4-r4)
(2/2) Installing postgresql (9.6.5-r0)
Executing busybox-1.26.2-r5.trigger
OK: 53 MiB in 29 packages
bash-4.3# cp /usr/bin/pg_dump /usr/bin/pg_dump
pg_dump pg_dumpall
bash-4.3# cp /usr/bin/pg_dump /usr/bin/pg_dump.back
bash-4.3# cp /usr/bin/pg_dumpall /usr/bin/pg_dumpall.back
bash-4.3# apk del postgresql
(1/2) Purging postgresql (9.6.5-r0)
(2/2) Purging libxml2 (2.9.4-r4)
Executing busybox-1.26.2-r5.trigger
OK: 38 MiB in 27 packages
bash-4.3# mv /usr/bin/pg_dump.back /usr/bin/pg_dump
bash-4.3# mv /usr/bin/pg_dumpall.back /usr/bin/pg_dumpall
bash-4.3# pg_dump
pg_dump: [archiver (db)] connection to database "root" failed: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
bash-4.3#
It is not ideal but it has worked for me in the past