When to want run SQL Server container, docker show sxited status - sql-server

After the pulling the SQL Server's container, when I want to run it, Docker shows me "exited" status when O execute this command:
docker ps -a
I tried this link but it did not help me:
https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-configure-docker?view=sql-server-ver15#troubleshooting
These are my container logs:
https://paste.fedoraproject.org/paste/dBBFlyulZ1Bera2caa84tA
I using Fedora 29 x86_x64 and my Docker client version is 18.09.6 Build 481bc77 and Docker-Ce is 19.03.4
(Sorry for my bad English)

This is because starting SQL-Server produces an error.
The error can be looked up in the error log.
Unfortunately, you can't access it, becaus the container terminates.
To lookup the error log, you need to have shared that directory...
On the host, create the location where the container stores the data:
sudo mkdir -p /var/opt/mssql
Create the docker-container with the data directory mapped:
docker pull mcr.microsoft.com/mssql/server:2017-latest
docker run -d -p 2017:1433 --name mssql_2017 -e MSSQL_SA_PASSWORD=TOP_SECRET -e ACCEPT_EULA=Y -e MSSQL_PID="Developer" -v /var/opt/mssql:/var/opt/mssql -d mcr.microsoft.com/mssql/server:2017-latest
(note: this maps port 1433 int he container to port 2017 on the host)
then, to start/stop the container:
docker start mssql_2017
docker stop mssql_2017
Now you can now look at the errors in /var/opt/mssql/log on your host machine.
Also, you can check if it works by connecting with sqlcmd:
For Fedora:
sudo su
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/msprod.repo
exit
sudo yum clean expire-cache
sudo yum check-update
sudo yum remove mssql-tools unixODBC-utf16-devel
sudo yum install mssql-tools unixODBC-devel
sudo ln -sfn /opt/mssql-tools/bin/sqlcmd /usr/bin/sqlcmd
sqlcmd -S localhost,2017 -U SA -P "<YourPassword>"
For Ubuntu:
sudo wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list)"
sudo apt-get update
sudo apt-get install mssql-tools
sudo ln -sfn /opt/mssql-tools/bin/sqlcmd /usr/bin/sqlcmd
sqlcmd -S localhost,2017 -U SA -P "<YourPassword>"

Related

Problem with apt-key in Microsoft ODBC driver installation for Ubuntu?

These commands are pulled from this site: https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver16#ubuntu18
sudo su
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools18
echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo apt-get install -y unixodbc-dev
These are Microsoft's official steps to install ODBC drivers on Ubuntu. I am not too familiar with Linux, so I do not know if using the deprecated apt-key commands will cause me any issues in the future. Could someone let me know if this is a reasonable concern? And if it is, what is the best practice to make my environment more stable for the future?
Thanks

Unable to install MSSQL Drivers PHP on Ubuntu 20.04I

I am basing myself on this guide: https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15#ubuntu18
Which gives the commands>
if ! [[ "18.04 20.04 21.04" == *"$(lsb_release -rs)"* ]];
then
echo "Ubuntu $(lsb_release -rs) is not currently supported.";
exit;
fi
sudo su
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools18
echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo apt-get install -y unixodbc-dev
But I keep getting the following errors
root#ip-172-31-80-13:/home/ubuntu# sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package msodbcsql18
root#ip-172-31-80-13:/home/ubuntu# # optional: for bcp and sqlcmd
root#ip-172-31-80-13:/home/ubuntu# sudo ACCEPT_EULA=Y apt-get install -y mssql-tools18
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package mssql-tools18
I have tested on a new instance and I get the same error

Docker timeout error mssql17 connection on M1 arm64 architecture

Could you please help me resolve this issue:
I must to say that everything is working fine on Windows amd64 architecture
But when I tried to start docker-compose on arm64 M1 it went wrong and makes the error
So I have these 2 Dockerfiles
FROM --platform=linux/amd64 python:3.9-buster as builder
WORKDIR ...
COPY ...
RUN apt-get update && apt-get install -y git g++ libgirepository1.0-dev unixodbc unixodbc-dev pkg-config libcairo2-dev gcc python3-dev
RUN pip install virtualenv &&\
python -m venv antenv
RUN . antenv/bin/activate &&\
python -m ensurepip --upgrade &&\
pip install --upgrade pip &&\
pip install wheel gobject PyGObject &&\
pip install -r requirements.txt
FROM --platform=linux/amd64 python:3.9-slim
WORKDIR ...
COPY --from=builder ...
RUN apt-get update && apt-get install curl gnupg -y
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - &&\
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list &&\
apt-get update &&\
ACCEPT_EULA=Y apt-get install msodbcsql17 mssql-tools -y &&\
apt-get install -y unixodbc python3-gi gir1.2-secret-1 alembic &&\
. antenv/bin/activate && pip install gunicorn &&\
mkdir -p /opt/antenv/nltk_data
EXPOSE 5000
CMD . antenv/bin/activate && alembic -x data=true upgrade head && gunicorn wsgi:app -w 1 --worker-class eventlet --threads 2 --forwarded-allow-ips=* -b 0.0.0.0:5000
and DataBase:
FROM --platform=linux/amd64 mcr.microsoft.com/mssql/server:2017-latest
WORKDIR /opt/mssql/
# Bundle config source
COPY ./*.sh /opt/mssql/bin/
RUN chmod +x /opt/mssql/bin/*.sh
ENTRYPOINT ["./bin/entrypoint.sh"]
CMD ["tail -f /dev/null"]
As you can see I mentioned everywhere that it is linux/amd64 platform
DataBase is upping good and I don`t get eerors
But when I up Backend, It as if does not see database and I get timeout error
backend | sqlalchemy.exc.OperationalError: (pyodbc.OperationalError) ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')
backend | (Background on this error at: https://sqlalche.me/e/14/e3q8)

How to verify ODBC version is the one on the odbc.ini file?

I have a requirement to configure shell to install specified version of ODBC.
The app that I'm configuring is an Angular app that uses janusgraph for storing data it is hosted on docker locally.
I updated the odbc.ini file, added the designed version. ref:https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15
I also updated the install-odbc.sh file and added the version details.
ACCEPT_EULA=Y apt-get -y install msodbcsql17=-17.8.so.1.1
# optional: for bcp and sqlcmd
ACCEPT_EULA=Y apt-get -y install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
apt-get install -y unixodbc-dev
# apt-show-versions msodbcsql17
msodbcsql17:amd64/bionic 17.8.1.1-1 uptodate
Then I deleted the app and installed it again from scratch, everything was successful and my app is backup and running on my local setup on docker.
The only challenge I have is how do I verify that indeed the ODBC version is the one on the odbc.ini file?
ODBC.ini
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.8.so.1.1
Description = MSSQL Server
Trace = Yes
Server = 10.0.0.0
Database = IT_D
Port = 1433
TDS_Version = 7.4
QuotedId = YES
AnsiNPW = YES
Encrypt = YES
TrustServerCertificate = YES
#VarMaxAsLong=YES
[Default]
Driver = /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.8.so.1.1
Docker file:
FROM ubuntu:18.04
# Create app directory
WORKDIR /root/importer
RUN apt-get -y update
# RUN apt-get -y install wget
# RUN wget https://rds-combined-ca-bundle.pem
# Wget not properly resolved by Jenkins, using local file as fallback
COPY ./rds-combined-ca-bundle.pem ./
COPY ./install-odbc.sh ./
RUN apt-get -y install gnupg2
RUN apt-get -y install dos2unix
RUN dos2unix ./install-odbc.sh
# Make sure the microsoft ODBC repository can be added as signed source
RUN apt-get -y update
RUN apt-get install -y curl apt-utils
RUN apt-get install -y apt-transport-https
# RUN apt-key adv --keyserver keyserver.ubuntu.com --keyserver-options http-proxy=${HTTP_PROXY} --recv-keys xxxxxx1229xx
RUN bash ./install-odbc.sh
# Node.js v14
RUN apt-get install -y git-core curl build-essential openssl libssl-dev python
RUN apt-get update -qq && apt-get clean
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get update -qq && apt-get clean
RUN apt-get -y install nodejs
RUN node -v
RUN npm -v
# Oracle installation
ENV ORACLE_INSTANTCLIENT_MAJOR 19.6
ENV ORACLE_INSTANTCLIENT_VERSION 19.6.0.0.0
ENV ORACLE /usr/local/oracle
ENV ORACLE_HOME $ORACLE/lib/oracle/$ORACLE_INSTANTCLIENT_MAJOR/client64
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:$ORACLE_HOME/lib
ENV C_INCLUDE_PATH $C_INCLUDE_PATH:$ORACLE/include/oracle/$ORACLE_INSTANTCLIENT_MAJOR/client64
RUN apt-get update && apt-get install -y libaio1 \
curl rpm2cpio cpio \
&& mkdir $ORACLE && TMP_DIR="$(mktemp -d)" && cd "$TMP_DIR" \
&& curl -L https://download.oracle.com/otn_software/linux/instantclient/19600/oracle-instantclient${ORACLE_INSTANTCLIENT_MAJOR}-basic-${ORACLE_INSTANTCLIENT_VERSION}-1.x86_64.rpm -o basic.rpm \
&& rpm2cpio basic.rpm | cpio -i -d -v && cp -r usr/* $ORACLE && rm -rf ./* \
&& ln -s libclntsh.so.${ORACLE_INSTANTCLIENT_MAJOR} $ORACLE/lib/oracle/$ORACLE_INSTANTCLIENT_MAJOR/client64/lib/libclntsh.so.$ORACLE_INSTANTCLIENT_MAJOR \
&& ln -s libocci.so.${ORACLE_INSTANTCLIENT_MAJOR} $ORACLE/lib/oracle/$ORACLE_INSTANTCLIENT_MAJOR/client64/lib/libocci.so.$ORACLE_INSTANTCLIENT_MAJOR \
&& echo "$ORACLE_HOME/lib" > /etc/ld.so.conf.d/oracle.conf && chmod o+r /etc/ld.so.conf.d/oracle.conf && ldconfig \
&& rm -rf /var/lib/apt/lists/* && apt-get purge -y --auto-remove curl rpm2cpio cpio
COPY ./dist/. ./
COPY ./package*.json ./
COPY ./tsconfig.json ./
# RUN npm install node-pre-gyp
RUN npm install
RUN node -v
COPY ./odbc.ini /etc/
RUN dos2unix /etc/odbc.ini
RUN cp /opt/microsoft/msodbcsql17/lib64/* /opt/microsoft/msodbcsql17/lib64/libmsodbcsql
RUN ls /opt/microsoft/msodbcsql17/lib64
COPY ./sqlnet.ora $ORACLE_HOME/network/admin/sqlnet.ora
RUN dos2unix $ORACLE_HOME/network/admin/sqlnet.ora
# CMD bash -c "npm run start:watch"
CMD bash -c "node --max-old-space-size=8192 ./app.js"
I tried to check docker logs but I couldn't file anything that indicates that the ODBC has been updated.
Can you please assist me with the steps to check the ODBC version used by my app.
Thanks in advance
Sivuyile

Change nginx default folder

Here what I have done:
1/ Use Google cloud as a server (Ubuntu 18) for admin page.
2/ Have a project react-js app, ex: abc
3/ Encrypt website www.sub.abc.com successfully, point to IP (Godday domain) on Google cloud successfully. (Source: https://linuxhint.com/redirecting_http_https/).
Problem: My app can not run on port 80, nginx took it! I have search many instructions but they
are not clear.
What I have done to fix this:
1/ Edit config file of nginx (https://www.tecmint.com/change-nginx-port-in-linux/).
2/ Export port 80 in my app. (export port=80 npm start).
Can not run my app on port 80 because something has taken that port?!
If I kill port 80 ===> nginx turn off.
Please give me the right way to change config file or replace nginx default folder to my app folder. Thank you!
I have deployed successfully. If you have the same problem. Can follow this.
DEPLOY
NPM + NODEJS
$ sudo apt-get install curl
$ curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
$ sudo apt-get install nodejs
NGINX
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install nginx
CONFIG
cd /
sudo mkdir app
sudo mkdir api
sudo mkdir html <=== git clone ...
cd /etc/nginx/conf.d
sudo touch api.conf
sudo vi api.conf
you can use the nginx as reverse proxy and change the port of you app for another like 8000 for example and configue in nginx:
server {
listen 80;
location / {
proxy_pass http://127.0.0.1:8000;
}
}
I have deployed successfully.
If you have the same problem. Can follow this.
DEPLOY
`$ sudo apt-get install curl
$ curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
$ sudo apt-get install nodejs`
NGINX
`$ sudo apt update
$ sudo apt upgrade
$ sudo apt install nginx`
CONFIG
`cd /
sudo mkdir app
sudo mkdir api
sudo mkdir html <=== git clone ...
cd /etc/nginx/conf.d
sudo touch api.conf
sudo vi api.conf`

Resources